Series 和 DataFrame 中的sort_index 方法
2017-04-24 12:38
302 查看
Series 的 sort_index(ascending=True) 方法可以对 index 进行排序操作,ascending 参数用于控制升序或降序,默认为升序。
若要按值对 Series 进行排序,当使用 .order(na_last=True, ascending=True, kind='mergesort') 方法,任何缺失值默认都会被放到 Series 的末尾。
在 DataFrame 上,.sort_index(axis=0, by=None, ascending=True) 方法多了一个轴向的选择参数与一个 by 参数,by 参数的作用是针对某一(些)列进行排序(不能对行使用 by 参数)。注意在使用sort_index对DataFrame进行排序的时候,不能直接对index和columns都含有的字段进行排序,会报错。
若要按值对 Series 进行排序,当使用 .order(na_last=True, ascending=True, kind='mergesort') 方法,任何缺失值默认都会被放到 Series 的末尾。
在 DataFrame 上,.sort_index(axis=0, by=None, ascending=True) 方法多了一个轴向的选择参数与一个 by 参数,by 参数的作用是针对某一(些)列进行排序(不能对行使用 by 参数)。注意在使用sort_index对DataFrame进行排序的时候,不能直接对index和columns都含有的字段进行排序,会报错。
相关文章推荐
- python中Series 和 DataFrame 中的sort_index 方法
- 浅谈Series和DataFrame中的sort_index方法
- python pandas ---Series,DataFrame 创建方法,操作运算操作(赋值,sort,get,del,pop,insert,+,-,*,/)
- python. pandas(series,dataframe,index) method test
- python sort、sort_index方法(排序)
- Series——series_custom&reindex&sort_index
- <Python数据分析>pandas, DataFrame, Index的方法delete和drop的区别
- pandas把dataframe转成Series,改变列中值的类型方法
- Python将DataFrame的某一列作为index的方法
- python pandas 对series和dataframe的重置索引reindex方法
- python sort、sort_index方法(排序)
- python sort、sort_index方法(排序)
- python sort、sort_index方法(排序)
- HP iPAQ hx2000 Pocket PC series (Windows Mobile 5.0)重启方法不同
- 深入聊聊Array的sort方法的使用技巧.详细点评protype.js中的sortBy方法
- Js中sort()方法的用法
- 深入聊聊Array的sort方法的使用技巧.详细点评protype.js中的sortBy方法
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- ASP.NET2.0中的GRIDVIEW控件在使用TemplateField中的LinkButton时如何在RowCommand事件中找到当前行index的方法
- Collections.sort()排序使用方法