-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: read_csv raising IndexError with multiple header cols, specified index_col and no data rows #38325
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
Conversation
… index_col and no data rows
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -729,6 +729,7 @@ I/O | |||
- :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:``read_*`` functions (:issue:`37909`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think italics are messed up bc the "read*" should have single-ticks instead of double-ticks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -729,6 +729,7 @@ I/O | |||
- :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:``read_*`` functions (:issue:`37909`) | |||
- :meth:`DataFrame.to_html` was ignoring ``formatters`` argument for ``ExtensionDtype`` columns (:issue:`36525`) | |||
- Bumped minimum xarray version to 0.12.3 to avoid reference to the removed ``Panel`` class (:issue:`27101`) | |||
- Bug in :meth:`read_csv` raising ``IndexError`` with multiple header columns and ``index_col`` specified when file has no data rows (:issue:`38292`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
meth -> func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, should we change the other too then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unforunately was a bit slow :(
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -726,9 +726,10 @@ I/O | |||
- :meth:`DataFrame.to_excel`, :meth:`Series.to_excel`, :meth:`DataFrame.to_markdown`, and :meth:`Series.to_markdown` now support writing to fsspec URLs such as S3 and Google Cloud Storage (:issue:`33987`) | |||
- Bug in :func:`read_fwf` with ``skip_blank_lines=True`` was not skipping blank lines (:issue:`37758`) | |||
- Parse missing values using :func:`read_json` with ``dtype=False`` to ``NaN`` instead of ``None`` (:issue:`28501`) | |||
- :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:``read_*`` functions (:issue:`37909`) | |||
- :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:`read_*` functions (:issue:`37909`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need to move to 1.3 (avail shortly)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove from 1.2 :->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, done
pandas/io/parsers.py
Outdated
# list of Nones GH#38292 | ||
index_names = [None] * len(ic) | ||
else: | ||
index_names, _, _ = _clean_index_names( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you generate this in _clean_index_names instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -222,3 +222,18 @@ def test_index_col_large_csv(all_parsers): | |||
result = parser.read_csv(path, index_col=[0]) | |||
|
|||
tm.assert_frame_equal(result, df.set_index("a")) | |||
|
|||
|
|||
def test_index_col_multiindex_columns_no_data(all_parsers): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add all the cases form the op (3 working & the non-working)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc change, ping on green.
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -726,9 +726,10 @@ I/O | |||
- :meth:`DataFrame.to_excel`, :meth:`Series.to_excel`, :meth:`DataFrame.to_markdown`, and :meth:`Series.to_markdown` now support writing to fsspec URLs such as S3 and Google Cloud Storage (:issue:`33987`) | |||
- Bug in :func:`read_fwf` with ``skip_blank_lines=True`` was not skipping blank lines (:issue:`37758`) | |||
- Parse missing values using :func:`read_json` with ``dtype=False`` to ``NaN`` instead of ``None`` (:issue:`28501`) | |||
- :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:``read_*`` functions (:issue:`37909`) | |||
- :meth:`read_fwf` was inferring compression with ``compression=None`` which was not consistent with the other :meth:`read_*` functions (:issue:`37909`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you remove from 1.2 :->
@jreback green |
lgtm, resolved conflict, though there is another PR that might conflict on whatsnew, but will see. |
Yeah, thanks for merging. As soon as we got a few messages in there we can vary the order a bit to avoid this |
thanks |
… index_col and no data rows (pandas-dev#38325) * BUG: read_csv raising IndexError with multiple header cols, specified index_col and no data rows * Adress comments * Add tests and move whatsnew * Revert change Co-authored-by: Jeff Reback <[email protected]>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Parser returned an empty list instead of a list filled with None, which caused the IndexError.