Table of Contents Preface What this book covers What you need for this book Running a Jupyter Notebook Who this book is for How to get the most out of this book Conventions Assumptions for every recipe Dataset Descr iptions Sections Getting ready Ho
直接上例子。
import pandas as pd
df = pd.DataFrame({'class':['a','a','b','b','a','a','b','c','c'],'score':[3,5,6,7,8,9,10,11,14]})
df:
class
score
0
a
3
1
a
5
2
b
6
3
b
7
4
a
8
5
a
9
6
b
10
7
c
11
8
c
14
df.sort_values(['class
Pandas–sort_values
## 参数
DataFrame.sort_values(by, axis=0, ascending=True, inplace=False, kind='quicksort', na_position='last')
#### 参数说明
axis:{0 or ‘index’, 1 or ‘columns’}, default 0,默认按照索引排序,即纵向排序,如果为1,则是横向排序
by:str or list of str;如果axis=0,那么by="列