When I transpose a dataframe, the headers are considered as "index" by default. But I want it to be a column and not an index. How do I achieve this ?
import pandas as pd dict = {'col-a': [97, 98, 99], 'col-b': [34, 35, 36], 'col-c': [24, 25, 26]} df = pd.DataFrame(dict) print(df.T) 0 1 2 col-a 97 98 99 col-b 34 35 36 col-c 24 25 26 Desired Output:
0 1 2 3 0 col-a 97 98 99 1 col-b 34 35 36 2 col-c 24 25 26