How To Set First Row of a Pandas Dataframe as Column Headers
Python
1| # Step 1: Get the first row of the Pandas dataframe and 2| # assign to new_header variable 3| new_header = df.iloc[0] 4| 5| # Step 2: Update the dataframe to only include rows after th 6| # the first row 7| df = df[1:] 8| 9| # Step 3: Set the dataframe column names as the new header variabe 10| df.columns = new_header
150
133
128
120