Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong index name during read_csv if using usecols #4201

Closed
tesla1060 opened this issue Jul 11, 2013 · 3 comments · Fixed by #5003
Closed

wrong index name during read_csv if using usecols #4201

tesla1060 opened this issue Jul 11, 2013 · 3 comments · Fixed by #5003
Labels
Duplicate Report Duplicate issue or pull request IO CSV read_csv, to_csv IO Data IO issues that don't fit into a more specific label
Milestone

Comments

@tesla1060
Copy link

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

@hayd
Copy link
Contributor

hayd commented Jul 11, 2013

Why not use index_col='Time' ?

What pandas version are you using? I get:

Exception: usecols not supported with engine='python' or multicharacter separators (yet).

#2733 and #3192

@cpcloud
Copy link
Member

cpcloud commented Jul 21, 2013

if you replace the spaces with , shouldn't this work? maybe close since this is a dupe?

paulgb pushed a commit to paulgb/pandas that referenced this issue Jul 26, 2013
@paulgb
Copy link

paulgb commented Jul 26, 2013

This is not a dupe of #2733, it also occurs when the separator is a comma. I've added a test case to my fork (using tesla's data).

I believe the issue is related to the order in which the index_col and usecols operations take place, but I'm not familiar enough with the code yet to fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request IO CSV read_csv, to_csv IO Data IO issues that don't fit into a more specific label
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants