When loading CSV data with pandas, the first line is mistaken for the title

1.5k Views Asked by At

How to prevent the following? When I load a file with pd.read_csv(), the first line gets unwantedly treated as a header (list of column names):

import pandas as pd
data = pd.read_csv('namefile',sep=' ')
print(data)

and only the second line onwards gets treated as the data (vector = np.array(data)).

1

There are 1 best solutions below

0
Akshay Sapra On BEST ANSWER

you can use the option of header to exclude columns data=pd.read_csv('namefile',sep=' ', header =None)