I want to reset my column headers in pandas. I want my column names to be my top row and then my column headers to be reset to 0,1,2,3 in pandas dataframe. How do i perform this operation?
one-liner
df.T.reset_index().T
You can change the column header names with .columns property of pandas dataframe. To reset it to 0,1,2,3.. use the following code
>>> df.columns = list(range(len(df.columns)))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With