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

read_csv() interprets index_col="True" as "1" #9798

Closed
kousu opened this issue Apr 3, 2015 · 2 comments · Fixed by #9835
Closed

read_csv() interprets index_col="True" as "1" #9798

kousu opened this issue Apr 3, 2015 · 2 comments · Fixed by #9835
Labels
API Design Error Reporting Incorrect or improved errors from pandas IO CSV read_csv, to_csv
Milestone

Comments

@kousu
Copy link

kousu commented Apr 3, 2015

epi.txt

OBS ID PERIOD TMT Y0 AGE COUNT
1 1 1 0 11 31 5
2 1 2 0 11 31 3
3 1 3 0 11 31 3
4 1 4 0 11 31 3
5 2 1 0 11 30 3
6 2 2 0 11 30 5
7 2 3 0 11 30 3
8 2 4 0 11 30 3
9 3 1 0 6 25 2
10 3 2 0 6 25 4
epi = pandas.read_csv("./epi.datn.txt", sep=" ", index_col=True)
print(epi)
    OBS  PERIOD  TMT  Y0  AGE  COUNT
ID                                  
1     1       1    0  11   31      5
1     2       2    0  11   31      3
1     3       3    0  11   31      3
1     4       4    0  11   31      3
2     5       1    0  11   30      3
2     6       2    0  11   30      5
2     7       3    0  11   30      3
2     8       4    0  11   30      3
3     9       1    0   6   25      2
3    10       2    0   6   25      4

I had some code that used False to disable reading indexes from the data, and was expecting True to be the opposite. Instead it read the second column, because True == 1 in python.

I think that True should be explicitly handled, because this behaviour is counterintuitive given that False is meaningful. False is not the same as index_col=0, after all.

@jreback jreback added this to the Next Major Release milestone Apr 4, 2015
@jreback
Copy link
Contributor

jreback commented Apr 4, 2015

I would not do this, rather it should raise if its True as its not an allowed value.

@jreback jreback added Error Reporting Incorrect or improved errors from pandas and removed Enhancement labels Apr 4, 2015
yanxiaole pushed a commit to yanxiaole/pandas that referenced this issue Apr 8, 2015
check at ``TextFileReader`` ``clean_options``
@jreback jreback modified the milestones: 0.16.1, Next Major Release Apr 8, 2015
yanxiaole pushed a commit to yanxiaole/pandas that referenced this issue Apr 9, 2015
BUG: pandas-dev#9798 `index_col` shouldn't accept the value `True`

move the check to ``TextFileReader`` ``clean_options``
@kousu
Copy link
Author

kousu commented Apr 11, 2015

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Error Reporting Incorrect or improved errors from pandas IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants