-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Fix correct warning with c engine when skipping lines #16455
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
Fix correct warning with c engine when skipping lines #16455
Conversation
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.
Thanks. Can you also add a release note in doc/source/whatsnew/0.20.2.txt
in the bug fixes section.
pandas/tests/io/parser/comment.py
Outdated
@@ -116,3 +118,29 @@ def test_commment_first_line(self): | |||
expected = DataFrame({0: ['a', '1'], 1: ['b', '2'], 2: ['c', '3']}) | |||
result = self.read_csv(StringIO(data), comment='#', header=None) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
def test_comment_whitespace_delimited(self): |
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.
You can use the tm.capture_stderr
decorator from pandas/util/testing.py
so you don't have to do the patching yourself. See
def test_skip_bad_lines(self): |
does this have an issue number? |
@TomAugspurger I have added the whatsnew bug entry and replaced |
can you rebase on master, CI has been fixed |
Fixed bug where c engine would not print warnings for lines it skipped in case the skipped line had an inline comment. Also, its accounting of number of fields in such lines would be off by one.
The behavior is only applicable on the `c` engine.
468d68b
to
44f4f00
Compare
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.
lgtm, minor comment.
doc/source/whatsnew/v0.20.2.txt
Outdated
@@ -53,6 +53,7 @@ Indexing | |||
I/O | |||
^^^ | |||
|
|||
- Bug in skipping error lines with inline comments in space delimited text files (:issue:`16472`) |
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.
something like this: Bug in pd.read_csv()
when comment
is passed in space deliminted text files.
@gfyoung if you can have a look |
Codecov Report
@@ Coverage Diff @@
## master #16455 +/- ##
=======================================
Coverage 90.42% 90.42%
=======================================
Files 161 161
Lines 51029 51029
=======================================
Hits 46144 46144
Misses 4885 4885
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #16455 +/- ##
=======================================
Coverage 90.42% 90.42%
=======================================
Files 161 161
Lines 51029 51029
=======================================
Hits 46144 46144
Misses 4885 4885
Continue to review full report at Codecov.
|
LGTM! |
Thanks @pankajp! |
…as-dev#16455) * Fix correct warning with c engine when skipping lines Fixed bug where c engine would not print warnings for lines it skipped in case the skipped line had an inline comment. Also, its accounting of number of fields in such lines would be off by one. * Use `tm.capture_stderr` to capture stderr * Add bug fix note in `whatsnew/v0.20.3.txt` * Move test to CParserTests The behavior is only applicable on the `c` engine. * Update whatsnew bug entry as per review (cherry picked from commit 97ad3fb)
* Fix correct warning with c engine when skipping lines Fixed bug where c engine would not print warnings for lines it skipped in case the skipped line had an inline comment. Also, its accounting of number of fields in such lines would be off by one. * Use `tm.capture_stderr` to capture stderr * Add bug fix note in `whatsnew/v0.20.3.txt` * Move test to CParserTests The behavior is only applicable on the `c` engine. * Update whatsnew bug entry as per review (cherry picked from commit 97ad3fb)
…as-dev#16455) * Fix correct warning with c engine when skipping lines Fixed bug where c engine would not print warnings for lines it skipped in case the skipped line had an inline comment. Also, its accounting of number of fields in such lines would be off by one. * Use `tm.capture_stderr` to capture stderr * Add bug fix note in `whatsnew/v0.20.3.txt` * Move test to CParserTests The behavior is only applicable on the `c` engine. * Update whatsnew bug entry as per review
Fixed bug where c engine would not print warnings for lines
it skipped in case the skipped line had an inline comment.
Also, its accounting of number of fields in such lines would
be off by one.
git diff upstream/master --name-only -- '*.py' | flake8 --diff