Skip to content

Pass the errors and kwargs arguments through to astype in the columns… #25888

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 12 commits into from
Mar 31, 2019

Conversation

johnklehm
Copy link
Contributor

… dict logic branch.

@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #25888 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25888      +/-   ##
==========================================
+ Coverage   91.47%   91.48%   +<.01%     
==========================================
  Files         175      175              
  Lines       52885    52885              
==========================================
+ Hits        48379    48380       +1     
+ Misses       4506     4505       -1
Flag Coverage Δ
#multiple 90.04% <100%> (ø) ⬆️
#single 41.82% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/generic.py 93.54% <100%> (ø) ⬆️
pandas/util/testing.py 89.84% <0%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95c78d6...7c2e092. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #25888 into master will increase coverage by 0.33%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #25888      +/-   ##
==========================================
+ Coverage   91.47%   91.81%   +0.33%     
==========================================
  Files         175      175              
  Lines       52885    52580     -305     
==========================================
- Hits        48379    48274     -105     
+ Misses       4506     4306     -200
Flag Coverage Δ
#multiple 90.36% <ø> (+0.32%) ⬆️
#single 41.9% <ø> (+0.07%) ⬆️
Impacted Files Coverage Δ
pandas/core/generic.py 93.54% <ø> (ø) ⬆️
pandas/compat/pickle_compat.py 69.13% <0%> (-6.48%) ⬇️
pandas/plotting/_compat.py 83.33% <0%> (-4.17%) ⬇️
pandas/core/config_init.py 96.96% <0%> (-2.24%) ⬇️
pandas/plotting/_style.py 77.17% <0%> (-0.49%) ⬇️
pandas/compat/numpy/__init__.py 92.85% <0%> (-0.48%) ⬇️
pandas/core/groupby/grouper.py 98.16% <0%> (-0.37%) ⬇️
pandas/plotting/_misc.py 38.46% <0%> (-0.23%) ⬇️
pandas/core/computation/engines.py 88.52% <0%> (-0.19%) ⬇️
pandas/plotting/_timeseries.py 65.28% <0%> (-0.18%) ⬇️
... and 76 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 95c78d6...343e26c. Read the comment docs.

@jreback
Copy link
Contributor

jreback commented Mar 27, 2019

what exactly are you trying to do? does this close an issue? always always need a test

@johnklehm
Copy link
Contributor Author

If you look at lines 5705 [0], 5732 [1] the calls to astype pass through the errors arg and kwargs. Only when the column names are passed as a dict are you not allowed to set the errors behavior.

How I ran into this was when I am calling astype on one column I can set errors='coerce' but when I am calling astype on a dict of columns this does not work.

I was hoping to get feedback on this approach.

[0] https://github.com/pandas-dev/pandas/pull/25888/files#diff-03b380f521c43cf003207b0711bac67fR5705
[1] https://github.com/pandas-dev/pandas/pull/25888/files#diff-03b380f521c43cf003207b0711bac67fR5732

@jreback
Copy link
Contributor

jreback commented Mar 27, 2019

you would be better off to write a test that shows the behavior
writing the code to latch is generally pretty easy once you have good reproducing tests

@gfyoung gfyoung added Error Reporting Incorrect or improved errors from pandas DataFrame DataFrame data structure labels Mar 27, 2019
@johnklehm
Copy link
Contributor Author

Updated with the test @jreback . Side note is that I was tempted to rename Generic to TestGeneric but I refrained. :)

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Can you also add a whatsnew note for v0.25?

…ck for the absense of the exception we'd normally throw. Assert the resulting dataframe against a reference dataframe. Move the test case to test_dtypes.
@johnklehm
Copy link
Contributor Author

johnklehm commented Mar 29, 2019

The whatsnew note is added in 0430b38

@johnklehm
Copy link
Contributor Author

Anything more I need to pursue on this?

…uldn't raise. Add a comment about addressing GH25905. Improve the dict formatting. Simplify the dict key names to make the test easier to read.
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

Minor nits

@pep8speaks
Copy link

pep8speaks commented Mar 31, 2019

Hello @johnklehm! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-03-31 00:32:36 UTC

@johnklehm
Copy link
Contributor Author

PEP8 E241 is normally off by default along with E226 E242....is the pep8speaks bot implying E241 is adhered to for pandas?

@WillAyd
Copy link
Member

WillAyd commented Mar 31, 2019

@johnklehm yep also need to fix up flake8 errors

…learer what is converted by astype. Swap the position of result and expected to match the style of the rest of the file.
@johnklehm
Copy link
Contributor Author

johnklehm commented Mar 31, 2019

I see 2 flake8 errors but don't think they're related to my changes:

./build/lib.linux-x86_64-3.7/pandas/_version.py:10:1: F401 'sys' imported but unused
./build/lib.linux-x86_64-3.7/pandas/tests/generic/test_generic.py:207:5: E303 too many blank lines (3)

Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

lgtm @jreback

@jreback jreback added this to the 0.25.0 milestone Mar 31, 2019
@jreback jreback merged commit de3a85c into pandas-dev:master Mar 31, 2019
@jreback
Copy link
Contributor

jreback commented Mar 31, 2019

thanks @johnklehm

@johnklehm johnklehm deleted the astype-dict-errors-fix branch March 31, 2019 12:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DataFrame DataFrame data structure Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants