I have a csv file that looks as follows:
,time,o,h,l,c
0,2021-03-17 09:30:00,101.25,103.98,90.17,101.78
1,2021-03-17 09:45:00,102.83,107.49,95.22,101.93
2,2021-03-17 10:00:00,100.92,102.90,97.19,102.80
I'm reading in this data using the read_csv function, as follows:
cols = ['indx', 'timestamp', 'open', 'high', 'low', 'close']
df = pd.read_csv('prices.csv', names=cols)
The resulting dataframe looks as follows:
Unnamed: 0 time o h l c
0 0 2021-03-17 09:30:00 101.25 103.98 90.17 101.78
1 1 2021-03-17 09:45:00 102.83 107.49 95.22 101.93
2 2 2021-03-17 10:00:00 100.92 102.90 97.19 102.80
Passing the names parameter seems to have no effect on the column names.
EDIT:
Passing the header parameter (per the docs) results in the same behavior:
cols = ['indx', 'timestamp', 'open', 'high', 'low', 'close']
df = pd.read_csv('prices.csv', header=0, names=cols)
Do I have to pass another parameter to the read_csv function to customize the column names?
Thanks!
headerparameter results in the same behavior.