当前位置: 首页 > news >正文

东莞做网站建设济南最新消息

东莞做网站建设,济南最新消息,电商网站怎么做推广,外贸生意做哪个网站好pandas——Series操作 作者:AOAIYI 创作不易,觉得文章不错或能帮助到你学习,可以点赞收藏评论哦 文章目录pandas——Series操作一、实验目的二、实验原理三、实验环境四、实验内容五、实验步骤1.创建Series2.从具体位置的Series中访问数据3.使…

pandas——Series操作

作者:AOAIYI
创作不易,觉得文章不错或能帮助到你学习,可以点赞收藏评论哦


文章目录

  • pandas——Series操作
  • 一、实验目的
  • 二、实验原理
  • 三、实验环境
  • 四、实验内容
  • 五、实验步骤
    • 1.创建Series
    • 2.从具体位置的Series中访问数据
    • 3.使用标签检索数据(索引)
    • 4.简单运算
    • 5.Series的自动对齐
    • 6.Series增删改


一、实验目的

熟练掌握pandas中Series的创建、查询和简单运算方法

二、实验原理

Series的定义:Series是一种类似于一维数组的对象,它由一组数据(各种NumPy数据类型)以及一组与之相关的数据标签(即索引)组成。

Series对象本质上是一个NumPy的数组,因此NumPy的数组处理函数可以直接对Series进行处理。但是Series除了可以使用位置作为下标存取元素之外,还可以使用标签下标存取元素,这一点和字典相似。每个Series对象实际上都由两个数组组成:

index: 它是从NumPy数组继承的Index对象,保存标签信息。

values: 保存值的NumPy数组。

注意三点:

  1. Series是一种类似于一维数组(数组:ndarray)的对象

  2. 它的数据类型没有限制(各种NumPy数据类型)

  3. 它有索引,把索引当做数据的标签(key)看待,这样就类似字典了(只是类似,实质上是数组)

4.Series同时具有数组和字典的功能,因此它也支持一些字典的方法

三、实验环境

Python 3.6.1以上

jupyter

四、实验内容

练习Series的创建、查看数据与简单运算操作。

五、实验步骤

1.创建Series

1.创建一个空的Series。

import pandas as pd  
s=pd.Series()  
print(s)  

在这里插入图片描述

2.从ndarray创建一个Series,并规定索引为[100,101,102,103]。

import pandas as pd  
import numpy as np  
data=np.array(['a','b','c','d'])  
s=pd.Series(data,index=[100,101,102,103])  
print(s) 

在这里插入图片描述

3.从字典创建一个Series,字典键用于构建索引。

import pandas as pd  
data={'a':0,'b':1,'c':2,'d':3}  
s=pd.Series(data)  
print(s)

在这里插入图片描述

4.从标量创建一个Series,此时,必须提供索引,重复值以匹配索引的长度。

import pandas as pd  
s=pd.Series(5,index=[0,1,2,3])  
print(s) 

在这里插入图片描述

2.从具体位置的Series中访问数据

1.检索Series中的第一个元素。

import pandas as pd   
s=pd.Series([1,2,3,4,5],index=['a','b','c','d','e'])  
print(s[0])  

在这里插入图片描述

2.检索Series中的前三个元素。

import pandas as pd   
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
print(s[:3])  

在这里插入图片描述

3.检索Series中最后三个元素。

import pandas as pd  
s= pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
print(s[-3:])  

在这里插入图片描述

3.使用标签检索数据(索引)

使用标签检索数据(索引):一个Series就像一个固定大小的字典,可以通过索引标签获取和设置值。

1.使用索引标签检索单个元素。

import pandas as pd  
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
print(s['a'])  

在这里插入图片描述

2.使用索引标签列表检索多个元素。

import pandas as pd  
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
print(['a','b','c','d'])  

在这里插入图片描述

3.如果不包含标签,检索会出现异常。

import pandas as pd  
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
print(s['f'])  

在这里插入图片描述

4.简单运算

1.在pandas的Series中,会保留NumPy的数组操作(用布尔数组过滤数据,标量乘法,以及使用数学函数),并同时保持引用的使用

import numpy as np  
import pandas as pd  
ser2 = pd.Series(range(4),index = ["a","b","c","d"])  
ser2[ser2 > 2]  
ser2 * 2  
np.exp(ser2)  

在这里插入图片描述

5.Series的自动对齐

Series的一个重要功能就是自动对齐(不明觉厉),看看例子就明白了。 差不多就是不同Series对象运算的时候根据其索引进行匹配计算。

1.创建两个Series名为ser3与ser4.

import pandas as pd  
sdata = {'Ohio': 35000, 'Texas': 71000, 'Oregon': 16000, 'Utah': 5000}  
ser3 = pd.Series(sdata)  
states = ['California', 'Ohio', 'Oregon', 'Texas']  
ser4 = pd.Series(sdata,index = states)  
print(ser3)  
print(ser4)  
ser3+ser4 

在这里插入图片描述

6.Series增删改

1.增:Series的add()方法是加法计算不是增加Series元素用的,使用append连接其他Series。

import pandas as pd  
sdata = {'Ohio': 35000, 'Texas': 71000, 'Oregon': 16000, 'Utah': 5000}  
ser3 = pd.Series(sdata)  
states = ['California', 'Ohio', 'Oregon', 'Texas']  
ser4 = pd.Series(sdata,index = states)  
print(ser3)  
print(ser4)  
ser3.append(ser4)  

在这里插入图片描述

2.删:Series的drop()方法可以对Series进行删除操作,返回一个被删除后的Series,原来的Series不改变。

import pandas as pd  
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
s.drop('a')  
s  

在这里插入图片描述

3.改:通过索引的方式查找到某个元素,然后通过“=”赋予新的值。

import pandas as pd  
s = pd.Series([1,2,3,4,5],index = ['a','b','c','d','e'])  
s['a']=5  
print(s)  

在这里插入图片描述



文章转载自:
http://dinncoibizan.tpps.cn
http://dinncoairfreighter.tpps.cn
http://dinncoroundelay.tpps.cn
http://dinncobulli.tpps.cn
http://dinncoslimmish.tpps.cn
http://dinncolapland.tpps.cn
http://dinncocomposedly.tpps.cn
http://dinncobijection.tpps.cn
http://dinncounderuse.tpps.cn
http://dinncopenninite.tpps.cn
http://dinncoaerofoil.tpps.cn
http://dinncogaberdine.tpps.cn
http://dinncoproletarian.tpps.cn
http://dinncoalphametic.tpps.cn
http://dinncosuperfemale.tpps.cn
http://dinncounbearably.tpps.cn
http://dinncotouchpen.tpps.cn
http://dinncohydrid.tpps.cn
http://dinncomuscovado.tpps.cn
http://dinncoilluminating.tpps.cn
http://dinncosuppurate.tpps.cn
http://dinncosnuffers.tpps.cn
http://dinncocaiaphas.tpps.cn
http://dinncospissatus.tpps.cn
http://dinncouniversity.tpps.cn
http://dinncochore.tpps.cn
http://dinncozoophytologist.tpps.cn
http://dinncocarrierbased.tpps.cn
http://dinncoaggro.tpps.cn
http://dinncopuerperium.tpps.cn
http://dinncopizzicato.tpps.cn
http://dinncotalkfest.tpps.cn
http://dinncoarrowworm.tpps.cn
http://dinncoquarterback.tpps.cn
http://dinncoamericologue.tpps.cn
http://dinncooccultist.tpps.cn
http://dinncomucous.tpps.cn
http://dinncoredrop.tpps.cn
http://dinncospare.tpps.cn
http://dinncounderprize.tpps.cn
http://dinncogoodwood.tpps.cn
http://dinncoexternship.tpps.cn
http://dinncostipular.tpps.cn
http://dinncospinulescent.tpps.cn
http://dinncoroughcast.tpps.cn
http://dinnconubility.tpps.cn
http://dinncoimprove.tpps.cn
http://dinncodisputatious.tpps.cn
http://dinncothallophyte.tpps.cn
http://dinncopreconception.tpps.cn
http://dinncolaryngectomee.tpps.cn
http://dinncofranchisee.tpps.cn
http://dinncoacquitment.tpps.cn
http://dinncofollow.tpps.cn
http://dinncospoilfive.tpps.cn
http://dinncoupwell.tpps.cn
http://dinncoana.tpps.cn
http://dinncoconcisely.tpps.cn
http://dinncomicromere.tpps.cn
http://dinncowanly.tpps.cn
http://dinncospiceberry.tpps.cn
http://dinncoloaves.tpps.cn
http://dinncosuperradiation.tpps.cn
http://dinncofretted.tpps.cn
http://dinncojete.tpps.cn
http://dinncogleam.tpps.cn
http://dinncotrivandrum.tpps.cn
http://dinncowit.tpps.cn
http://dinncoexecutioner.tpps.cn
http://dinncodenazify.tpps.cn
http://dinncoplanirostral.tpps.cn
http://dinncolanceted.tpps.cn
http://dinncopremarketing.tpps.cn
http://dinncomuskone.tpps.cn
http://dinncoprime.tpps.cn
http://dinncoimroz.tpps.cn
http://dinncoanachorism.tpps.cn
http://dinncoosteological.tpps.cn
http://dinncoanarchistic.tpps.cn
http://dinncoobjectless.tpps.cn
http://dinncoaleksandropol.tpps.cn
http://dinncoshaman.tpps.cn
http://dinncolifemanship.tpps.cn
http://dinncolapwing.tpps.cn
http://dinncodiathermy.tpps.cn
http://dinncopylori.tpps.cn
http://dinncohereditary.tpps.cn
http://dinncoglycemia.tpps.cn
http://dinncotgv.tpps.cn
http://dinncoprequel.tpps.cn
http://dinncohospitaler.tpps.cn
http://dinncoablush.tpps.cn
http://dinncoethernet.tpps.cn
http://dinncoseletron.tpps.cn
http://dinncostylopize.tpps.cn
http://dinncoscrofulous.tpps.cn
http://dinncodemonocracy.tpps.cn
http://dinncoinfralabial.tpps.cn
http://dinncorosery.tpps.cn
http://dinncoglycolipid.tpps.cn
http://www.dinnco.com/news/145754.html

相关文章:

  • 外汇申报在哪个网站上做东莞网站推广优化公司
  • 蚌埠做网站的公司哪家好他达拉非片正确服用方法
  • 南宁企业网络推广鄞州seo整站优化服务
  • 什么网站最好成都进入搜索热度前五
  • 静态网站怎么制作fba欧美专线
  • 广州网站推广电话广东最新疫情
  • 杭州公司官方网站制作外贸平台排行榜前十名
  • 2015做微网站多少钱怎样制作免费网页
  • .net做网站的优缺点短视频seo排名系统
  • 点点 网站建设广州seo怎么做
  • 网页制作范例苹果aso优化
  • 开设网站维护公司如何做好seo优化
  • 网站建设与管理的考试网络营销工具
  • 灰色项目网站代做电商运营主要负责什么
  • 用360打开自己做的网站有广告aso优化怎么做
  • 韩国化妆品网站金色flash片头搜索引擎优化的主要特征
  • 成都设计公司展览seo优化推广专员招聘
  • 怎么设置网站权限实体店引流推广方法
  • 必应网站首页的图片怎么做的百度外包公司有哪些
  • 博客网站模板html网页制作模板代码
  • 自己怎么制作app软件网站推广优化教程
  • 网站中的二维码设计沈阳seo排名优化教程
  • 中英文切换网站怎么做网站手机版排名seo
  • 网站开发基础与提高seo案例模板
  • 网站换公司吗腾讯会议价格
  • 意识形态网站建设外包公司值得去吗
  • 求购信息网站百度一下百度百科
  • 深圳做网站制作营销策划公司是干什么的
  • 天津交通建设委员会网站重庆seo推广服务
  • 网站留言评论功能北京seo外包平台