-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
read_table / read_csv with duplicate names leads to column duplication #10496
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
Comments
pls show a self-contained example reproducing the behavior |
tbl.csv:
...gives you:
...rather than:
i.e. it repeats the number of columns equal to the number of unique given names, starting from the right. |
@forodin23 by self-contained I mean simple code, not having to download a file etc.
In answer to your question there is nothing pandas can do about this. Its not obvious that what you are doing is wrong. If you want to actually have a column hierarchy, much better to use a MultiIndex, or if you really really want duplicate columns (this is not recommended and use at your own risk), then simply assign them after. |
Why don't you just give an error message if someone tries to use duplicate names? The problem here is that pandas silently changes your data. |
hmm also a problem here. Ok this might be an older bug. I suppose a case could be made for raising here (or rather assigning by position if the names match up). There are several cases to investigate. pull-request? |
A pull request by me? Sorry, I'm using python for about a day (coming from matlab). I don't feel equipped to fix that myself :) |
ok, np. always a good way to learn though :) see here for guidelines |
dupe of #9424 |
When reading a table while specifying duplicate column names - let's say two different names - pandas 0.16.1 will copy the last two columns of the data over and over again.
I opened a thread on this here:
http://stackoverflow.com/questions/31207560/pandas-read-table-with-duplicate-names
Is this a bug or an intended behavior?
The text was updated successfully, but these errors were encountered: