Answers for "pandas sort by column name descending"

1

reverse column order pandas

import pandas as pd

df = pd.DataFrame({'a':[1,2,3],
                   'b':[4,5,6,],
                   'c':[7,8,9,]})

df_col_reversed = df.loc[:, ::-1] # reverse column order
df_row_reversed = df.loc[::-1, :] # reverse row order
Posted by: Guest on July-10-2021
2

pandas sort columns by name

df = df.reindex(sorted(df.columns), axis=1)
Posted by: Guest on November-26-2020

Code answers related to "pandas sort by column name descending"

Python Answers by Framework

Browse Popular Code Answers by Language