Skip to content

wrong index name during read_csv if using usecols #4201

Closed
@tesla1060

Description

@tesla1060

Hi,

If I have a test.csv file looks like below

SecId    Time               Price    P2    P3
10000   2013-5-11       100      10     1
500       2013-5-12     101      11     1

if I read in the above file with the following code

df =pd.read_csv('test.csv', usecols=['Time', 'Price'], parse_dates=True, index_col=0)

then df.index.name will be SecId instead of Time

Metadata

Metadata

Assignees

No one assigned

    Labels

    Duplicate ReportDuplicate issue or pull requestIO CSVread_csv, to_csvIO DataIO issues that don't fit into a more specific label

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions