相关知识
本关我们将学习处理Series和DataFrame中的数据的基本手段,我们将会探讨Pandas最为重要的一些功能。
对索引进行排序
Series用sort_index()按索引排序,sort_values()按值排序;
DataFrame也是用sort_index()和sort_values()。
In[73]: obj = Series(range(4), index=['d','a','b','c'])
In[74]: obj.sort_index()
Out[74]:
a 1
b 2
c 3
d 0
dtype: int64
In[78]: frame = DataFrame(np.arange(8).reshape((2,4)),index=['three',

本篇博客介绍如何使用Pandas对Series和DataFrame进行数据排序。通过sort_index()和sort_values()函数,可以实现对索引和值的排序。示例中详细展示了对Series和DataFrame按索引及按值排序的方法。
最低0.47元/天 解锁文章
1752

被折叠的 条评论
为什么被折叠?



