MatMorPau22 :
Let's say I have a DataFrame and don't know the names of all columns. However, I know there's a column called "N_DOC"
and I want this to be the first column of the DataFrame - (while keeping all other columns, regardless its order).
How can I do this?
Serge Ballesta :
You can reorder the columns of a datframe with reindex
:
cols = df.columns.tolist()
cols.remove('N_DOC')
df.reindex(['N_DOC'] + cols, axis=1)