DEPR: deprecate Index.is_numeric by ABCPAN-rank · Pull Request #50769 · pandas-dev/pandas (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
- progress towards API: Deprecate Index.is_(boolean|categorical|integer|floating|numeric|object|interval) #50042
- Tests added and passed if fixing a bug or adding a new feature
- All code checks passed.
- Added type annotations to new arguments/methods/functions.
- Added an entry in the latest
doc/source/whatsnew/vX.X.X.rstfile if fixing a bug or adding a new feature.
ABCPAN-rank changed the title
warm user is_numeric will be deprecated warn user is_numeric will be deprecated
ABCPAN-rank changed the title
warn user is_numeric will be deprecated DEPR: deprecate Index.is_numeric
@topper-123 hellow friend , i have changed all is_numeric . But it still have a check failing . I want to know where lead to this failing . Can you help me to pass this check ?
Hi @ABCPAN-rank. Thanks for this. You're getting close. A couple issues:
- You need to add a test add a test that this is deprecated, named
test_is_numeric_is_deprecatedor similar. Look at the other PRs how this is done. - The method is still used in some places, check the
Doc Build and Upload / Doc Build and Upload (pull_request)failures. Usage of this method should removed entirely from the code base, except from the test that it is deprecated. - You use
is_numeric_dtype(x) and not is_complex_dtype(x) and not is_bool_dtype(x)consistently. Can you check if this is necessary or if this check should be relaxed in some places.
Can you look at the above, especially point 3. If those three checks in point 3 are really needed as much as indicated here, can you add a helper function in pandas.core.dtypes.common for this, so we only have to use a single function instead of 3.
- I think
test_is_numeric_deprecatedwhich is same as other PR had been added inpandas/tests/indexes/common.py. - I think all
.is_numeric()was changed(except test) after i usegit grep "is_numeric()".But check is failing. atDoc Build and UploadIt have 5 warnings inDoc Build and Upload. I cannot find the warning path
3..is_numeric()(Only real number) is different fromis_numeric_dtype()(including boolean and complex) in number field. if we useis_numeric_dtype()instead of.is_numeric(), we need a helper function . so what's name should be called about this helper function ?is_real_dtypes?
- Yes I had missed that, sorry
- I looked at it, and I think it is is an external package that used the method (dask), so probably is ok as-is. I've restarting the doc build test, maybe the failure was a fluke and it'll pass on a second try.
- Yes, but could you check if we really should check for bools and complex numbers in all those locations. it may have been done without considering the difference and now is a good time to check if using
is_numeric_dtypeonly is sufficient. If they're needed,is_real_dtypesis probably not a good name (complex numbers are not real as far as I remember my math), but e.g.is_any_numeric_dtypeor similar is fine.
@topper-123 ok, i will check it .
But is_numeric() will return False when index include complex or boolean. I think if we want to use a helper function instead of is_numeric() , we can use is_real_dtype() . Because is_numeric() is check real number in actually .It will return True when input is only int or float.
@topper-123 If I use a helper function to instead of is_numeric(), should I write some tests for helper function? Where can write the tests? Or I can use old test about is_numeric() .
No, That's not needed, this is just internal and very simple. is_real_dtype is not good for a name, if it's checking other types than real numbers.
@topper-123 Ok i will write a helpful function called is_any_numeric_dtype .
Should I change doc/source/whatsnew/v2.0.0.rst for is_any_numeric_dtype?
Should I change
doc/source/whatsnew/v2.0.0.rstforis_any_numeric_dtype?
No, this should be a purely internal detail, so a whatsnew entry is not needed.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, it looks good, just needs to pass the remaining tests.
For the errors in Doc Build and Upload / Doc Build and Upload I'm not 100 % if it is the problem, but try to add a :okwarning: below the relevant .. ipython:: python sections. You can see where the doc tests complain about dask using is_numeric in the test logs.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Labels
Functionality to remove in pandas
Related to the Index class or subclasses