这个模块下有的10个功能,似乎都是对数据进行数组,数据类型之类的转化。不过感觉这个模块下面的内容使用价值不太大,简单过一下。
astype(1):将Series中的数据类型转变,使用上还是可以比较灵活的,dtype(进行数据类型的转变),copy(如果定义了copy的Series被其它pandas对象使用,可能会影响其它pandas对象的数据类型),errors(控制异常是否抛出,raise ,ignore )。
list0 = [1,2,3]dp = pd.Series(data=list0,dtype=str)print(dp.astype)print(dp.astype(dtype=int).dtype)print(dp.astype(int).dtype)list0 = [1,2,'asa']dp = pd.Series(data=list0,dtype=str)#这里如果errors='raise'就会抛出异常print(dp.astype(dtype=int,errors='ignore'))
convert_dtypes(2):将数据转化为可能的数据类型
list0 = [1,2,3]dp = pd.Series(data=list0)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数组,感觉意义不大
