-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Add type check for encoding_errors in pd.read_csv #59075
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
pandas/io/parsers/readers.py
Outdated
@@ -1413,6 +1413,13 @@ def _make_engine( | |||
raise ValueError( | |||
f"Unknown engine: {engine} (valid options are {mapping.keys()})" | |||
) | |||
|
|||
errors = self.options.get("encoding_errors", "strict") | |||
if not isinstance(errors, str) and errors is not None: |
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.
if not isinstance(errors, str) and errors is not None: | |
if not isinstance(errors, str): |
pandas/io/parsers/readers.py
Outdated
@@ -1413,6 +1413,13 @@ def _make_engine( | |||
raise ValueError( | |||
f"Unknown engine: {engine} (valid options are {mapping.keys()})" | |||
) | |||
|
|||
errors = self.options.get("encoding_errors", "strict") |
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.
Could you move this logic into _read
?
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.
Okay, I have moved it into _read
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.
Could you add a whatsnew note in v3.0.0.rst
and a unit test?
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.
Could you add a unit test?
Co-authored-by: Matthew Roeschke <[email protected]>
Co-authored-by: Matthew Roeschke <[email protected]>
Co-authored-by: Matthew Roeschke <[email protected]>
Co-authored-by: Matthew Roeschke <[email protected]>
Could you add a unit test to validate the exception message? |
Ok, I added a test. |
pandas/tests/io/test_common.py
Outdated
@@ -590,6 +590,24 @@ def test_encoding_errors(encoding_errors, format): | |||
tm.assert_frame_equal(df, expected) | |||
|
|||
|
|||
@pytest.mark.parametrize("encoding_errors", [0, None, "strict"]) |
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.
Don't need to test "strict"
here
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.
OK
Co-authored-by: Matthew Roeschke <[email protected]>
Co-authored-by: Matthew Roeschke <[email protected]>
Thanks @Aliebc |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.