user5997
0
Q:

python dataframe sort by column name

df = df.reindex(sorted(df.columns), axis=1)
1
DataFrame.sort_values(self, by, axis=0, ascending=True,
                      inplace=False, kind='quicksort',
                      na_position='last',
                      ignore_index=False)

# Example
df.sort_values(by=['ColToSortBy'])
0
df = df.reindex(sorted(df.columns), axis=1)
0
>>> result = df.sort(['A', 'B'], ascending=[1, 0])
0

New to Communities?

Join the community