Closed
Description
Pandas 0.12
When specifying usecols with read_csv it seems impossible to use an implicit (no header) index column
Example:
>>> data = 'a,b,c\n4,apple,bat,5.7\n8,orange,cow,10'
>>> pd.read_csv(StringIO(data))
a b c
4 apple bat 5.7
8 orange cow 10.0
>>> pd.read_csv(StringIO(data), usecols=['a', 'b'])
a b
0 apple bat
1 orange cow
>>>
Where you would prefer/expect this:
>>> pd.read_csv(StringIO(data), usecols=['a', 'b'])
a b
4 apple bat
8 orange cow
Specifying index_col = 0 would give:
>>> pd.read_csv(StringIO(data), usecols=['a', 'b'], index_col = 0)
b
apple bat
orange cow
So this would only work if we explicity pass the column to be used as an index to usecols. However, we cannot explicitly pass an implicit index column to usecols as the index column is not named (it has no header).
Metadata
Metadata
Assignees
Labels
No labels