Skip to content

BUG: read_csv may interpret second row as index names even if index_col is False #47397

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

Merged
merged 3 commits into from
Jun 21, 2022

Conversation

phofl
Copy link
Member

@phofl phofl commented Jun 17, 2022

I think index_col should take precedence over guessing

@phofl phofl added Bug IO CSV read_csv, to_csv labels Jun 17, 2022
@@ -466,6 +466,17 @@ def test_index_col_false_and_header_none(python_parser_only):
0.5,0.03
0.1,0.2,0.3,2
"""
result = parser.read_csv(StringIO(data), sep=",", header=None, index_col=False)
with tm.assert_produces_warning(ParserWarning, match="Length of header"):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was already showing the warning before (which is correct), hence I added the check

@mroeschke mroeschke added this to the 1.5 milestone Jun 21, 2022
@mroeschke mroeschke merged commit fd9b2a4 into pandas-dev:main Jun 21, 2022
@mroeschke
Copy link
Member

Thanks @phofl

@phofl phofl deleted the 46569 branch June 21, 2022 19:50
yehoshuadimarsky pushed a commit to yehoshuadimarsky/pandas that referenced this pull request Jul 13, 2022
…ol is False (pandas-dev#47397)

* BUG: read_csv may interpret second row as index names even if header is integer

* BUG: read_csv may interpret second row as index names even if index_col is False

* BUG: read_csv may interpret second row as index names even if index_col is False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug IO CSV read_csv, to_csv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: ENH: Allow callable for on_bad_lines in read_csv when engine="python" #45146
2 participants