pandas retaining index column when using usecols
I am trying to read a csv file which has a column of row indexes which is
not named. The rest of the columns are named:
|head1|head2|
index1 | data1 | data2 |
when I read in a certain number of columns with usecols, I also want to
include the row indexes. However, as these are not named, I can't include
the string in my list for usecols. I've tried doing a combination of an
integer index and strings (e.g. usecols = [0, 'header1', 'header2'] but
this does not seem to work. If I simply specify ind_col as 0, it will use
the first column in my selection as the index column.
So, how can I read in a name column selection (via usecols) whilst
retaining the first, nameless, column in the file as my row index?
No comments:
Post a Comment