pandas基础__之__对数据进行筛选和排序

本文介绍了如何使用Pandas的.sort_values()和.loc()函数对数据进行筛选和排序。详细讲解了单列和多列数据的排序,以及如何结合.loc进行筛选后的排序操作。示例代码展示了如何根据deviceId筛选数据,并按speed列进行升序排序。
摘要由CSDN通过智能技术生成

使用Pandas对数据进行筛选和排序

在Pandas中通过.sort和.loc函数也可以实现这两 个功能。.sort函数可以实现对数据表的排序操作;.loc函数可以实现对数据表的筛选操作。

对值进行排序

pandas.DataFrame.sort_values

DataFrame. sort_values ( by,   axis=0,   ascending=True,   inplace=False,   kind='quicksort',   na_position='last' ) [source]

Sort by the values along either axis

New in version 0.17.0.

Parameters:

by : str or list of str

Name or list of names which refer to the axis items.

axis : {0 or ‘index’, 1 or ‘columns’}, default 0

Axis to direct sorting

ascending : bool or list of bool, default True

Sort ascending vs. descending. Specify list for multiple sort orders. If this is a list of bools, must match the length of the by.

inplace : bool, default False

if True, perform operation in-place

kind : {‘quicksort’, ‘mergesort’, ‘heapsort’}, default ‘quicksort’

Choice of sorting algorithm. See also ndarray.np.sort for more information. mergesortis t

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值