DataFrame.sort()

pandas.DataFrame.sort

DataFrame.sort(columns=None, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last', **kwargs) [source]

DEPRECATED: use DataFrame.sort_values()

Sort DataFrame either by labels (along either axis) or by the values in column(s)

Parameters:

columns : object

Column name(s) in frame. Accepts a column name or a list for a nested sort. A tuple will be interpreted as the levels of a multi-index.

ascending : boolean or list, default True

Sort ascending vs. descending. Specify list for multiple sort orders

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

Sort index/rows versus columns

inplace : boolean, default False

Sort the DataFrame without creating a new instance

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

This option is only applied when sorting on a single column or label.

na_position : {‘first’, ‘last’} (optional, default=’last’)

‘first’ puts NaNs at the beginning ‘last’ puts NaNs at the end

Returns:

sorted : DataFrame

Examples

>>> result = df.sort(['A', 'B'], ascending=[1, 0])

© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
http://pandas.pydata.org/pandas-docs/version/0.19.2/generated/pandas.DataFrame.sort.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部