I am new to python so this may sound very basic. I have imported a csv file using csv2rec. The first row has headers. I want to change the headers to ‘x’, ‘y’, ‘z’. What’s the best way of doing this?
>>> import matplotlib
>>> import matplotlib.mlab as mlab
>>> r= mlab.csv2rec('HeightWeight.csv', delimiter= ',')
>>> names= r.dtype.names
>>> for i in names:
print i
index
heightinches
weightpounds
mlab.csv2rec has a
namesparameter which you can use to set the column names:When
namesis notNone,csv2recassumes there is no header row. So useskiprows=1to ignore the header row.