zoukankan      html  css  js  c++  java
  • 数据分析之pandas01

    Series
    一.Series
    Series是一种类似于一维数组的对象,有两部分组成:
        .values:一组数据(ndarray类型)
        .index: 相关的数据索引标签
    二.series的创建
        1.由列表或numpy数组创建
             Series(data=[1,2,3,4],index=['a','b','c','d'],name='haha',dtype='int64')
             index为显示索引,name为标识,dtype指定数据类型
             Serier(data=np.arange(10,60,6))
        2.由字典创建:不能再使用index,但是依然存在默认索引
    三.Serier的索引和切片
      1.索引
          可以使用中括号取单个索引(此时返回的是元素类型),或者中括号里一个列表取多个索引(此时返回的是Series类型)
           (1)显式索引:a.使用index中的元素作为索引值,b.使用s.loc[],推荐:loc中放的一定是显式索引
           (2)隐式索引:a.使用整数作为索引值,b.使用s.iloc[],推荐:iloc中放的一定是隐式索引
      2.切片
          (1)显式索引切片:index和loc
          (2)隐式索引切片:整数索引和iloc
    四.Series的基本操作
    1.可以把Series看成一个定长的有序字典,向Series增加一行,相当于给字典增加一组键值对
        a['f'] = 99
    2.可以使用s.head(),tail()分别查看前n个和后n个值
    3.对Series去重
             s.unique()   Series中的去重函数 
    4.Serise运算.
         (1)在运算中自动对齐不同索引的数据
             如果索引不对齐,则补NaN
         (2)a.add()加, a.sub()减 , a.mul()乘, a.div()除
    5.可以使用pd.isnull(),pd.notnull或s.isnull,notnull()函数检测缺失数据
        去除空值(NaN):检测,过滤s.loc[s.notnull()]只能用loc()
    五.Series属性
        1.shape
        2.size
        3.index
        4.values
  • 相关阅读:
    Ubuntu 16.04 not a com32r image
    重定向输出遇到的缓冲问题
    you don't have permission to access / on this server解决
    LaTeX入门简介
    解决eclipse中出现Resource is out of sync with the file system问题
    Ubuntu安装新英伟达驱动出现问题解决方法
    同步与异步的区别
    Cuda入门笔记
    解决 Cocos2d-x 3.2 error C1041: 无法打开程序数据库vc120.pdb
    vs2013编译过程中,错误 59 error C4996: 'GetVersionExW': 被声明为已否决
  • 原文地址:https://www.cnblogs.com/hu13/p/9355079.html
Copyright © 2011-2022 走看看