Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

make first row columns 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

pandas first row to header

see the difference between these two lines
#no header
data= pd.read_csv(path, header = None, delim_whitespace=True, error_bad_lines=False)
#with headers
data= pd.read_csv(path, delim_whitespace=True, error_bad_lines=False)
Comment

PREVIOUS NEXT
Code Example
Python :: my pygame window wont stay open 
Python :: python numpy kurtosis 
Python :: python is integer 
Python :: write file with python 
Python :: print() in python 
Python :: empty directory if not empty python 
Python :: from sklearn.externals import joblib instead use..... 
Python :: indices of true boolean array pyton 
Python :: np.loadtext 
Python :: binomial coefficient python 
Python :: remove empty strings from list python 
Python :: print python 
Python :: how to get current date in python 
Python :: opencv skip video frames 
Python :: how to slice dataframe based on daterange in pandas 
Python :: how to sort a list in python using lambda 
Python :: round list of floats python 
Python :: get cuda memory pytorch 
Python :: python argparse include default information 
Python :: TabError: inconsistent use of tabs and spaces in indentation 
Python :: python execute command with variable 
Python :: how to format integer to two digit in python 
Python :: openpyxl xls 
Python :: python yaml load_all 
Python :: how to convert multi list to dict 
Python :: TinyDB 
Python :: python csv reader 
Python :: creating dictionary using the keys 
Python :: cyclically rotate an array by one 
Python :: Python __gt__ magic method 
ADD CONTENT
Topic
Content
Source link
Name
6+1 =