ENH: make Series.ptp() handle missing values #11163
Labels
Missing-data
np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Numeric Operations
Arithmetic, Comparison, and Logical operations
Milestone
Currently (in master),
Series.ptp()
is just implemented usingnp.ptp()
and so the method will returnnan
for any Series that has one or more missing values:It is simple to write
s.max() - s.min()
instead, but theptp()
result is surprising as most pandas methods are designed to handle missing data gracefully. I think most users would expect theptp()
method to ignoreNaN
.If there is any agreement as to whether
ptp()
should be changed, I would like to work on a pull request!Extending the idea, it might be useful to have both
DataFrame.ptp()
andgroupby.ptp()
methods.For this example DataFrame...
...I would expect the following behaviour:
Again, if there is any consensus from the community on whether these additional methods should be added, I'd be happy to work on the pull request.
The text was updated successfully, but these errors were encountered: