DEPR update dedeprecation message for np.ptp  #28665 #6581
State: closed

- ref : https://github.com/pandas-dev/pandas/issues/28665#issuecomment-567499869 #6581
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`



Labels:
name: Deprecate
description: Functionality to remove in pandas

Comments:
The fix here is not to update the warning but to remove Series.ptp entirely
Here in #28665
https://github.com/pandas-dev/pandas/issues/28665#issuecomment-567499869
It was suggested that till the time this resolved we should update the message
> agree with @jbrockmendel let's just remove this entirely. it has been deprecated for a while and we are removing code for 1.0

so, for now, I have updated the message, 
I believe it will take some time for getting rid of np,ptp() till then this message should help.
> > agree with @jbrockmendel let's just remove this entirely. it has been deprecated for a while and we are removing code for 1.0
> 
> so, for now, I have updated the message,
> I believe it will take some time for getting rid of np,ptp() till then this message should help.

no, for 1.0 we *are* going to remove this code, if you want to repurpose this PR to do it great.
Ohhk no isssues
I would love to do it
As I am new to the codebase it would be really nice if you can give me some pointers around achieving this
> Ohhk no isssues
> I would love to do it
> As I am new to the codebase it would be really nice if you can give me some pointers around achieving this

ok, you remove the code & associated tests, see https://dev.pandas.io/docs/whatsnew/v1.0.0.html#removal-of-prior-version-deprecations-changes for things that we *have* removed, so add an entry liek this
so I removed code and tests for ptp
remove the part where series only functions are added
removed the entire series only function because ptp was the only series only function
deleted tests for pandas ptp function
but the test written for np.ptp gives me a future warning 

`
____________________________________________________________ TestSeriesAnalytics.test_ptp ____________________________________________________________

self = <pandas.tests.series.test_analytics.TestSeriesAnalytics object at 0x7f666e0267b8>

    def test_ptp(self):
        # GH21614
        N = 1000
        arr = np.random.randn(N)
        ser = Series(arr)
        with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
>           assert np.ptp(ser) == np.ptp(arr)

pandas/tests/series/test_analytics.py:861: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <contextlib._GeneratorContextManager object at 0x7f666e03ad30>, type = None, value = None, traceback = None

    def __exit__(self, type, value, traceback):
        if type is None:
            try:
>               next(self.gen)
E               AssertionError: Did not see expected warning of class 'FutureWarning'

/usr/lib/python3.6/contextlib.py:88: AssertionError
================================================ 1 failed, 163 passed, 1 skipped, 3 xfailed in 1.96s =================================================
`
tests are not failing at local no clue why azure pipelines are failing

`
(pandas-dev) moha@moha-HP-Pavilion-Notebook:~/projects/pandas-hasnain2808$ pytest pandas/tests/series/test_analytics.py
============================= test session starts ==============================
platform linux -- Python 3.6.9, pytest-5.3.2, py-1.8.0, pluggy-0.13.1
rootdir: /home/moha/projects/pandas-hasnain2808, inifile: setup.cfg
plugins: cov-2.8.1, forked-1.1.3, xdist-1.30.0, hypothesis-4.54.0
collected 168 items                                                            

pandas/tests/series/test_analytics.py ..........................s....... [ 20%]
........................................................................ [ 63%]
..............................................x.....x.....x...           [100%]

================== 164 passed, 1 skipped, 3 xfailed in 3.26s ===================
`


What was happening in the failing builds is that when we call `np.ptp(ser)` numpy first checks if `ser` has a `ptp` method, in which case it calls that.  This PR removes (removed) that method, so numpy is falling back to whatever it tries next, probably involving either `__array__` or `__array_func__` or something.  Whatever that something is, it's returning a Series when it should return a scalar.
> What was happening in the failing builds is that when we call `np.ptp(ser)` numpy first checks if `ser` has a `ptp` method, in which case it calls that. This PR removes (removed) that method, so numpy is falling back to whatever it tries next, probably involving either `__array__` or `__array_func__` or something. Whatever that something is, it's returning a Series when it should return a scalar.

So I actually had tried what is numpy returning on my local machine. Over there it's returning float
And also it would be nice if you could guide me a bit more towards the solution of this numpy issue
> What was happening in the failing builds is that when we call `np.ptp(ser)` numpy first checks if `ser` has a `ptp` method, in which case it calls that. This PR removes (removed) that method, so numpy is falling back to whatever it tries next, probably involving either `__array__` or `__array_func__` or something. Whatever that something is, it's returning a Series when it should return a scalar.

As I am unable to reproduce this on my local machine I tried to push a commit with the print statements which are ignored by the pipeline.
Also only builds on some platforms are failing not all
[link to the azure build](https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=23868&view=results)

mac os python 3.6
linux python 3.6 minimum version
linux python 3.6 32 bit
windows python 3.7 np 141


checking the logs show me that the series returned by numpy is all True boolean series

2019-12-25T01:57:55.8017700Z self = 0      True
2019-12-25T01:57:55.8017950Z 1      True
2019-12-25T01:57:55.8018210Z 2      True
2019-12-25T01:57:55.8018480Z 3      True
2019-12-25T01:57:55.8018720Z 4      True
2019-12-25T01:57:55.8018980Z        ... 
2019-12-25T01:57:55.8019230Z 995    True
2019-12-25T01:57:55.8019480Z 996    True
2019-12-25T01:57:55.8019740Z 997    True
2019-12-25T01:57:55.8019990Z 998    True
2019-12-25T01:57:55.8020250Z 999    True
2019-12-25T01:57:55.8020500Z Length: 1000, dtype: bool
2019-12-25T01:57:55.8020730Z 

if it would have been returning a series with just the correct values it would have been simple to extract it, but the returned series is not correct.
At last all tests passing
Requesting some reviewer to check it 
thanks for the effort @hasnain2808 I had already merged #30458 

happy to take a contribution on other issues.