Skip to content
Advertisement

How to convert first column of dataframe in to its headers

I have dataframe df:

JavaScript

O/P should be:

JavaScript

I want column containing(a, b,c,d,e) as header of my dataframe.

Could anyone help?

Advertisement

Answer

If your dataframe is pandas and its name is df. Try solving it with pandas:

Firstly convert initial df content to a list, afterwards create a new dataframe defining its columns with the list.

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement