How to convert a Pandas DataFrame row to column headers in Python

Converting a Pandas DataFrame row to column headers takes the value of each element in the row and sets it as the header of that column.

Solution for How to convert a Pandas DataFrame row to column headers in Python : You can use pandas.DataFrame.columns to convert a row to column headersAccess the row of column headers with pandas.DataFrame.iloc and the indexing syntax [header_row] with header_row as the index of the row with column headers. Assign the result to pandas.DataFrame.columns to set the column headers in pandas.DataFrame to the values in the header row. Call pandas.DataFrame.drop(labels) with labels as the index of the header row to remove the header row from pandas.DataFrame. Call pandas.DataFrame.reset_index(drop=True) to reset the row index of pandas.DataFrame.


how-to-convert-a-pandas-dataframe-row-to-column-headers-in-python