• 02-pandas数据Serious


    import pandas as pd
    from pandas import Series
    import numpy as np
    from pandas import DataFrame
    obj=Series([1,2,3,4,5])#Series包含行索引,列索引。默认0,1,2,3,4
    obj2=Series([1,2,3,4,5],index=["a","b","c","d","e"])#自定义索引
    
    arr1=np.arange(10)
    obj3=Series(arr1,index=["a","b","c","d","e","f","h","j","k","l"])#索引对不上就会报错,索引要唯一
    
    obj3=Series({"11111":1234,"abcabc":2222})
    gk=Series([150,150,150,300],index=["数学","英语","语文","理科综合"])
    
    obj4=Series([11,12,13,14,15])
    print(obj4[0:2])#前提索引是数字
    # print(testobj.loc(3))#标识索引对象
    print(obj4.loc[0])#loc下标取值
    
    obj5=Series([11,12,13,14,15],index=["a","b","c","d","e"])
    # print(obj5.loc[3])#非数字索引loc取值就会报错
    print(obj5[0:3])#非数字索引但是常规取值可以
    print(obj5["a":"c"])
    print(obj5.loc["d"])#loc取值
    print(obj5.iloc[0:2 ])
    #自定义索引obj[]既可以是数字也可以是自定义
    #obj.loc[]只能是自己定义索引
    #loc按照实际索引
    #iloc按照数字所以
    """
    Series
    A=对象
    A[0]:根据数字索引取出数据
    A[1:3]:根据数字索引切片
    A["a"]:根据自定义索引取出数据
    A["a","b"]:根据自定义索引切片
    loc:#按照自定义索引
    iloc:按照索引
    """
    
    
    print(obj5.shape)#形状
    print(obj5.size)#多少元素
    print(obj5.values)#返回数组的数值,numpy
    print(obj5.head())#查看默认前五行,输入10就是前十行
    print(obj5.tail())#查看尾部
    
    mydict={"a":1,"b":2,"c":3}
    index=["a","b","x"]#不在索引的数据会被狐狸,Nan不存在
    obj6=Series(mydict,index=index)
    
    print(pd.isnull(obj6))#判断数据是否完整
    print(pd.notnull(obj6))#判断数据不为空
    obj6.name="自定义名称"
    print(obj6.name)
    print(obj6+2)#表示每个数都加二
    print(obj6[obj6>1])#数据筛选
    
    A=Series([1,2,3],index=["a","b","c"])
    B=Series([11,22,33],index=["a","b","c"])
    print(A+B)#计算索引要一致
    
    A=Series([1,2,3],index=["a","b","c1"])
    B=Series([11,22,33],index=["a","b","c"])
    print(A.add(B,fill_value=0))#索引不对等的加上零
    #a     12.0
    # b     24.0
    # c     33.0
    # c1     3.0
    

      

  • 相关阅读:
    Oracle DUL/AUL/ODU 工具说明
    Mysql 不同版本 说明
    Oracle RAC ASM disk header 备份 恢复 与 重建 示例说明
    Oracle checkpoint 说明
    Oracle RBA(Redo Byte Address) 说明
    Oracle wrap 和 unwrap( 加密与解密) 说明
    Oracle 10.2.0.5.4 Patch Set Update (PSU) – Patch No: p12419392
    Oracle RAC CSS 超时计算 及 参数 misscount, Disktimeout 说明
    Oracle 估算数据库大小的方法
    Oracle 11g 11.2.0.2 Bug 10082277 – Excessive allocation in PCUR or KGLH0 heap of “kkscsAddChildNo”
  • 原文地址:https://www.cnblogs.com/wcyMiracle/p/12436125.html
Copyright © 2020-2023  润新知