Skip to content

Updated qcut for Float64DType Issue #40730 #40969

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 9 commits into from
Apr 26, 2021
Merged

Conversation

taytzehao
Copy link
Contributor

This PR is used to address #40730 . qcut is now able to support both intdtype and floatdtype

@taytzehao
Copy link
Contributor Author

taytzehao commented Apr 16, 2021

@github-actions pre-commit

@mzeitlin11
Copy link
Member

Thanks for the pr @taytzehao! Can you please add tests that fail before this fix, but pass after? I think pandas/tests/reshape/test_qcut.py is the right place (and has some good examples). Can you also add a whatsnew note for 1.3 (see examples in doc/source/whatsnew/v1.3.0.rst)

@mzeitlin11 mzeitlin11 added Bug cut cut, qcut NA - MaskedArrays Related to pd.NA and nullable extension arrays labels Apr 16, 2021
@pep8speaks
Copy link

pep8speaks commented Apr 18, 2021

Hello @taytzehao! 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 2021-04-19 09:51:16 UTC

@@ -695,7 +695,7 @@ Conversion
- Bug in :class:`Index` construction silently ignoring a passed ``dtype`` when the data cannot be cast to that dtype (:issue:`21311`)
- Bug in :meth:`StringArray.astype` falling back to numpy and raising when converting to ``dtype='categorical'`` (:issue:`40450`)
- Bug in :class:`DataFrame` construction with a dictionary containing an arraylike with ``ExtensionDtype`` and ``copy=True`` failing to make a copy (:issue:`38939`)
-
- Bug in :func:`_coerce_to_type` failing to convert ``Float64DType`` input into numpy array (:issue:`40730`)
Copy link
Member

Choose a reason for hiding this comment

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

Whatsnew entries should reference behavior that users see. So instead of an internal function, it should mention the effect on qcut, something like Bug in :meth:pandas.qcut raising for nullable float types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Will resolve it accordingly.

pd.qcut(series, 2)
except:
Fail_string = Data_type_string + " is not supported"
pytest.fail(msg=Fail_string)
Copy link
Member

@mzeitlin11 mzeitlin11 Apr 18, 2021

Choose a reason for hiding this comment

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

What are you trying to test here? If you're trying to test that something works, this try/except structure is not needed, if it actually raises the test will just fail as desired by default.

It might be helpful to try to follow examples from above - construct result from using qcut, then compare to an expected result that you hardcode.

I'd recommend just folding into the test above - you could just parameterize the test above by any_nullable_numeric_dtype type instead of any_nullable_int_dtype rather than adding a new test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. thanks

@taytzehao
Copy link
Contributor Author

@github-actions pre-commit

@taytzehao
Copy link
Contributor Author

@mzeitlin11 , let me know what you think

@jreback jreback added this to the 1.3 milestone Apr 26, 2021
@jreback jreback merged commit ee18cb5 into pandas-dev:master Apr 26, 2021
@jreback
Copy link
Contributor

jreback commented Apr 26, 2021

thanks @taytzehao nice way to fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug cut cut, qcut NA - MaskedArrays Related to pd.NA and nullable extension arrays
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants