Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

make first row column names pandas

new_header = df.iloc[0] #grab the first row for the header
df = df[1:] #take the data less the header row
df.columns = new_header #set the header row as the df header
Comment

make first row column names pandas

df.rename(columns=df.iloc[0])
Comment

make first row column names pandas

In [24]: df.drop(df.index[1])
Out[24]: 
1 foo bar baz
0   1   2   3
2   4   5   6
Comment

PREVIOUS NEXT
Code Example
Python :: python read file txt and return list of each lines 
Python :: how to import subprocess in python 
Python :: pandas convert float to int with nan null value 
Python :: python write 
Python :: getting pi in python 
Python :: remove python2 centos 
Python :: python opens windows store 
Python :: does break stop all loops 
Python :: how to download excel file from s3 using python 
Python :: create a new file in python 3 
Python :: pyspark groupby sum 
Python :: how to say hello world in python 
Python :: python move item in list to end 
Python :: python module with alphabet list 
Python :: python csv read header only 
Python :: list loop python 
Python :: pyqt5 qpushbutton disable 
Python :: remove nana from np array 
Python :: Basic method of Converting List to Dataframe 
Python :: django rest framework simple jwt 
Python :: how to change kay bindings in pycharm 
Python :: c vs python 
Python :: pip install vlc 
Python :: psyche 
Python :: how to show pandas last record 
Python :: django custom primary key field 
Python :: read pdf py 
Python :: check if float is integer python 
Python :: python os filename without extension 
Python :: __gt__ 
ADD CONTENT
Topic
Content
Source link
Name
1+1 =