Skip to content

ENH: make Series.ptp ignore NaN values (GH11163) #11172

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 1 commit into from
Nov 14, 2015

Conversation

ajcr
Copy link
Contributor

@ajcr ajcr commented Sep 22, 2015

Closes GH11163.

Series.ptp will now ignore missing values when calculating the peak to peak difference.

@jreback
Copy link
Contributor

jreback commented Sep 24, 2015

actually what I would is define this using generic.py/_make_stat_function (e.g. how .min and such are defined). though this would only apply to Series (so might need to move a couple of things around to deal with this).

@jreback jreback added Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Numeric Operations Arithmetic, Comparison, and Logical operations labels Sep 24, 2015
@ajcr
Copy link
Contributor Author

ajcr commented Sep 24, 2015

Ah OK - no problem, I should be able to take a look at this and update in the next week or so.

@ajcr ajcr changed the title ENH: make Series.ptp to ignore NaN values (GH11163) ENH: make Series.ptp ignore NaN values (GH11163) Oct 3, 2015
@jreback jreback modified the milestones: 0.17.0, 0.17.1 Oct 5, 2015
@@ -487,6 +487,8 @@ Other enhancements

- ``pd.read_csv`` is now able to infer compression type for files read from AWS S3 storage (:issue:`11070`, :issue:`11074`).

- ``Series.ptp`` will now ignore missing values by default (:issue:`11163`)
Copy link
Contributor

Choose a reason for hiding this comment

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

move to 0.17.1

Copy link
Contributor

Choose a reason for hiding this comment

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

put in the API section as we are going to change the signature a bit

@jreback
Copy link
Contributor

jreback commented Oct 9, 2015

can you update

@ajcr
Copy link
Contributor Author

ajcr commented Oct 10, 2015

Apologies - the past few weeks have been much busier than I'd anticipated. I hope to get back to update this very soon.

@jreback
Copy link
Contributor

jreback commented Oct 11, 2015

no prob.

@jreback
Copy link
Contributor

jreback commented Nov 10, 2015

@ajcr progress?

@jreback jreback modified the milestones: Next Major Release, 0.17.1 Nov 13, 2015
@jreback
Copy link
Contributor

jreback commented Nov 13, 2015

@ajcr pls update when you can

@ajcr
Copy link
Contributor Author

ajcr commented Nov 13, 2015

@jreback: my apologies for the delay once again, I've just got back and was looking at this again just now.

As I understand it, I need to do the following:

  • make a nanptp function in nanops.py (is implementing this as nanmax - nanmin sufficient?)
  • add an entry for ptp to _make_stat_function in generic.py
  • make sure that this doesn't become a method of DataFrame - i.e. retrict it to Series

The last part I'm not quite sure how to do best, because NDFrame is a parent class of both Series and DataFrame. Are there any other methods from NDFrame that are restricted to one or the other object in this way?

@jreback
Copy link
Contributor

jreback commented Nov 13, 2015

you don't really need to do step 1, simply define it in _make_stat_function to do this (as its sort of a trivial function)

if you look at the end of core/series.py there is a like Series._add_numeric_operations(), (and in DataFrame), so you just need to tag certain of these functions to be added only on certain classes.

@ajcr
Copy link
Contributor Author

ajcr commented Nov 14, 2015

@jreback: made some changes and things are now green - let me know if you'd like me to improve anything or make any other changes.

@jreback jreback modified the milestones: 0.17.1, Next Major Release Nov 14, 2015
jreback added a commit that referenced this pull request Nov 14, 2015
ENH: make Series.ptp ignore NaN values (GH11163)
@jreback jreback merged commit 28bfb14 into pandas-dev:master Nov 14, 2015
@jreback
Copy link
Contributor

jreback commented Nov 14, 2015

thanks!

@ajcr
Copy link
Contributor Author

ajcr commented Nov 14, 2015

No problem (sorry it took a while) - thanks for your guidance!

@ajcr ajcr deleted the ptp-handle-nan branch November 14, 2015 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants