-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
DOC: Improved the docstring of errors.ParserWarning #20076
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
Changes from 2 commits
abdc710
0607602
850a3fe
815bf0e
b12907e
8fe1c04
37c9f96
17687b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,37 @@ class EmptyDataError(ValueError): | |
|
||
class ParserWarning(Warning): | ||
""" | ||
Warning that is raised in `pd.read_csv` whenever it is necessary | ||
to change parsers (generally from 'c' to 'python') contrary to the | ||
one specified by the user due to lack of support or functionality for | ||
parsing particular attributes of a CSV file with the requested engine. | ||
Warning raised in `pd.read_csv` and `pd.read_table` when it is | ||
necessary to change parsers, generally from 'c' to 'python'. | ||
|
||
It happens due to lack of support or functionality for parsing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. due to a lack for parsing a particular attribute |
||
particular attributes of a CSV file with the requested engine. | ||
|
||
Currently, C-unsupported options include the following parameters: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'c' unsupported options |
||
|
||
1. `sep` other than a single character (e.g. regex separators) | ||
2. `skipfooter` higher than 0 | ||
3. `sep=None` with `delim_whitespace=False` | ||
|
||
The warning can be avoided by adding `engine='python'` as a parameter | ||
in `pd.read_csv` and `pd.read_table` methods. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a |
||
Examples | ||
-------- | ||
Using a `sep` in `pd.read_csv` other than a single character: | ||
|
||
>>> import io | ||
>>> csv = u'''a;b;c | ||
... 1;1,8 | ||
... 1;2,1''' | ||
>>> df = pd.read_csv(io.StringIO(csv), sep='[;,]') | ||
Traceback (most recent call last): | ||
... | ||
ParserWarning: Falling back to the 'python' engine... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you check why the validation says that this test didn't pass, and that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I ran the code in my console I had this warning displayed: I thought it might have something to do as it is a warning and not an error. Something along the lines that the kind of output generated by an error could be caught by Traceback but not the output of a warning. Any ideas on how to fix and approach this? |
||
|
||
Adding `engine='python'` to `pd.read_csv` removes the Warning: | ||
|
||
>>> df = pd.read_csv(io.StringIO(csv), sep='[;,]', engine='python') | ||
""" | ||
|
||
|
||
|
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.
The first line needs to fit in a line. Can you write something more concise please? This paragraph is really useful, and it surely needs to be in the description, but the first line is used in some summaries that should be shorter. Something like
Warning raised when reading a table does not use the default parser
. Not sure if it's accurate or fits in one line, but to give you an idea.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.
Great Mark! Thanks for the suggestion. Already commited my version of it.