-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Parse two date columns broken in read_csv with multiple headers #15376
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
so your csv is invalid as far as multi-line parsing goes. It 'works' but is not very useful. A multi-line csv header needs non-sparsity (this is in fact how '.to_csv' writes it).
I think we have a an issue to parse it with the sparsity but not sure. So it parses correctly when the names are given (as tuples). I suppose its a bug that And so your original example parses when the columns are fully declared. (though again not very useful).
Further make a single level is just not useful in a multi-level frame. I would prob do this:
So in summary I'll mark this as a bug, but you have other issues. |
Wow, thanks for nice response. Do you mind if I cross post this response on Stack Overflow? Also, the problem exists with/without the sparsity. It is the tuple causing the problem. A proposed fix is running in the CI now, I will submit a PR shortly. Thanks again for your quick and very detailed attention. |
sure. Its not the tuple, rather the positional indexers which look up the tuple. |
In `io/parsers/_try_convert_dates()` when selecting columns based on a column index from a set of columns with multi- level names, the column `name` was converted to a string. This appears to be a bug since the `name` was a tuple before the conversion. This causes problems downstream when there is an attempt to use this name to lookup a column, and that lookup fails because the desired column is keyed from the tuple, not its string representation closes pandas-dev#15376 Author: Stephen Rauch <[email protected]> Closes pandas-dev#15378 from stephenrauch/fix_read_csv_merge_datetime and squashes the following commits: 030f5ec [Stephen Rauch] BUG: Parse two date columns broken in read_csv with multiple headers
Problem description
As can be seen here, a
KeyError
is being thrown when when trying to merge two date columns from acsv
with multiple header lines.So this
csv
file:Causes this line:
to raise a
KeyError
NOTE: I will be submitting a PR shortly.
Output of
pd.show_versions()
pandas: 0.19.2
nose: 1.3.7
pip: 8.1.2
setuptools: 18.2
Cython: None
numpy: 1.12.0
dateutil: 2.6.0
pytz: 2016.6.1
The text was updated successfully, but these errors were encountered: