这个模块下有的10个功能,似乎都是对数据进行数组,数据类型之类的转化。不过感觉这个模块下面的内容使用价值不太大,简单过一下。

    astype(1):将Series中的数据类型转变,使用上还是可以比较灵活的,dtype(进行数据类型的转变),copy(如果定义了copy的Series被其它pandas对象使用,可能会影响其它pandas对象的数据类型),errors(控制异常是否抛出,raise ,ignore )。

    1. list0 = [1,2,3]
    2. dp = pd.Series(data=list0,dtype=str)
    3. print(dp.astype)
    4. print(dp.astype(dtype=int).dtype)
    5. print(dp.astype(int).dtype)
    6. list0 = [1,2,'asa']
    7. dp = pd.Series(data=list0,dtype=str)
    8. #这里如果errors='raise'就会抛出异常
    9. print(dp.astype(dtype=int,errors='ignore'))

    convert_dtypes(2):将数据转化为可能的数据类型

    1. list0 = [1,2,3]
    2. dp = pd.Series(data=list0)
    3. print(dp.infer_objects())

    inferobjects(3):将数据类型变为更合理的数据类型
    copy(4):复制数据和索引,用处不大的感觉
    bool(5):Series内只能有单个bool值,否则无法判断,好鸡肋的功能。
    tonumpy(6):转化为numpy数组,感觉意义不大
    to_period(7):转化为周期索引,感觉没什么用处
    to_timestamp(8):意义不大
    to_list(9):意义不大
    __array
    (10):转化为numpy数组,感觉意义不大