pandas Series

从实际意义上说pandas的DataFrame结构是一个矩阵,但是他又不是矩阵,

DataFrame 和Series,Series其实是DataFrame的一列数据,多个Series组成了一个DateFrame结构;

通过Series可以给一列中的某一个值指定一个索引:

如:

series_custom= Series(price.value,index=house_info['province'].values)

更DataFrame结构一样:他也有对排过序的某一列,可以把混乱的下标重置;

series_custom = series_custom.sort_values('price')

series_custom.reindex(series_custom)

sort_index() :是按照键值对进行排序的;

series 还可以进行相加;

字符和数字都可以做索引,并且当字符做索引的时候还可以通过字符索引做切片;


猜你喜欢

转载自blog.csdn.net/weixin_38859557/article/details/80990763