import pandas as pd;
import numpy as np
#通过一维数组创建
Chinese = np.array([89,87,86])
print(Chinese)
print(pd.Series(Chinese))
print(pd.Series(Chinese,index=['xiaoming','xiaohong','xiaohei'],dtype='float'))
#通过字典创建
Chinese2={"小红":98,"小黑":76,"小王":65}
score = pd.Series(Chinese2)
print(score)
print(score.index)
abc = score.index=list('abc')#修改索引值
print("====================================")
print(score.values)
#设置数据变量名
score.name='语文'
score.index.name='姓名'
print(score)
#axes 获取索引
print(score.axes)
print(score.index)
#empty 是否为空
print(score.empty) #head tail 返回前几行 返回后几行
scores = pd.Series(np.random.randint(60,100,20));
print(scores)
print(scores.head(3))
#p排序 取前几名
print(scores.sort_values(ascending=False).head(3))
#Series值获取 索引值可以重复
ser1 = pd.Series([33,22,55,72,63],index=list('abcde'));
print(ser1)
print(ser1['c'])#index取值
print(ser1[3])#下表取值
print(ser1['b':'d'])#切片 索引切片是包含末尾的
print(ser1[1:4])#下表切片 不包含末尾
#!!如果重复index 利用这个重复值去切片就会报错
#Series运算
print(Chinese)
Chinese_ser1 = pd.Series(Chinese)
Chinese_ser1.index = ['小红','小黑','小王']
print(Chinese_ser1)
Match_ser1 = pd.Series({"小红":88,"小黑":99,"小王":70,"海涛":"1"})
total_ser1 = Match_ser1 + Chinese_ser1
print(total_ser1) #np是依赖位置相加,Series是根据index去相加的(自动对齐)
#缺失值检测
print(total_ser1.isnull())#notnull 非空检测

最新文章

  1. Page Scroll Effects - 简单的页面滚动效果
  2. 《好设计不简单Ⅱ:UI设计师必须了解的那些事》
  3. JAVA基础知识之网络编程——-使用MutilcastSocket实现多点广播
  4. OpenResty 反向代理的用法与技巧
  5. git push 提示
  6. MySQL密码忘记之解决方法
  7. SQL SERVER 2008 架构
  8. 通信协议:HTTP、TCP、UDP(转)
  9. UVa 11879 - Multiple of 17
  10. Hadoop加zookeeper构建高可靠集群
  11. Unity 类似FingerGestures 的相机跟随功能
  12. layui框架部分功能介绍
  13. Linux 配置Jenkins
  14. xss框架基础框架实现
  15. 密码\路径\IP...备忘录
  16. cc1plus.exe: error: unrecognized command line option "-fno-keep-inline-dllexport "
  17. poj-2115-exgcd
  18. php array_rand()函数从数组中随机选择一个或多个元素
  19. 小峰mybatis(2)mybatis传入多个参数等..
  20. linux shell学习-1

热门文章

  1. CSIC_716_20191108【文件的操作,以及彻底解决编码问题的方案】
  2. layui中的tab切换
  3. Python代码中func(*args, **kwargs)
  4. Delphi 窗口置顶的方法
  5. pca算法实现
  6. mysql 新特性之geometry
  7. x-杂项-maven-repository-lombok:lombok
  8. poj-3468-A Simple Problem with Integers-线段树入门+区间更新
  9. 深入分析Service启动、绑定过程
  10. 面试系列22 dubbo的工作原理