Sorting rows

If you wish to sort a DataFrame by the value of one of its columns, that can be done using the sort_values() function; simply specify the column name as the first parameter. ascending is an optional parameter that lets you specify the sorting direction:

df3 = df3.sort_values('new_col4', ascending=True)
print(df3)

The output is as follows:

  col3 new_col1  new_col2  new_col3  new_col4  new_col5  new_col6
2    z                  0         9         1       1.0        12
3    a                  0        11         1       1.0        13
4    b                  0        13         1       1.0        14
0    x                  0         5         5       7.0        10
1    y                  0         7         7       8.0        11
5    c                  0        15        21       9.5        15
6    d                  0        17        23      10.5        16
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset