Answers for "pandas sort only one column"

2

python sort dataframe by one column

#following is example of sorting by the column "2" in descending order
final_df = df.sort_values(by=['2'], ascending=False)
Posted by: Guest on May-12-2021
1

pandas dataframe sort by column name first 10 values

print df
   0  Bytes  Client             Ip
0  1      1    1000   192.168.10.2
1  0      0    2000  192.168.10.12
2  2      2     500   192.168.10.4
3  3      3     159  192.168.10.56

print df.nlargest(3, 'Client')
   0  Bytes  Client             Ip
1  0      0    2000  192.168.10.12
0  1      1    1000   192.168.10.2
2  2      2     500   192.168.10.4
Posted by: Guest on December-13-2020
0

sort pandas dataframe by specific column

In [18]:
df.sort_values('2')

Out[18]:
        0          1     2
4    85.6    January   1.0
3    95.5   February   2.0
7   104.8      March   3.0
0   354.7      April   4.0
8   283.5        May   5.0
6   238.7       June   6.0
5   152.0       July   7.0
1    55.4     August   8.0
11  212.7  September   9.0
10  249.6    October  10.0
9   278.8   November  11.0
2   176.5   December  12.0
Posted by: Guest on May-06-2021

Code answers related to "pandas sort only one column"

Python Answers by Framework

Browse Popular Code Answers by Language