Skip to content

ENH: Add an axis parameter to DataFrame.diff #9727

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
Apr 29, 2015

Conversation

evanpw
Copy link
Contributor

@evanpw evanpw commented Mar 25, 2015

No description provided.

@TomAugspurger
Copy link
Contributor

+1 on adding this parameter. I think the axis should be flipped though, right? axis=0 is a difference along the index, i.e. df.iloc[1] - df.iloc[0]. Similar to how cumsum operates along the index.

See also np.diff.

@jreback jreback added Reshaping Concat, Merge/Join, Stack/Unstack, Explode API Design Compat pandas objects compatability with Numpy or Python functions labels Mar 25, 2015
@jreback jreback added this to the 0.16.1 milestone Mar 25, 2015
@@ -16,7 +16,7 @@ We recommend that all users upgrade to this version.

Enhancements
~~~~~~~~~~~~

- ``DataFrame.diff`` now takes an ``axis`` parameter
Copy link
Contributor

Choose a reason for hiding this comment

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

pls add the issue number (which is the PR number, e.g. 9727)

@evanpw
Copy link
Contributor Author

evanpw commented Mar 26, 2015

@TomAugspurger: You're right about np.diff having a different convention. All of the internal diff machinery (in core.internals.Block, core.common, and C implementations in algos) has this opposite convention as well, but maybe I'll just invert the axis in this public facing DataFrame.diff method.

@jreback
Copy link
Contributor

jreback commented Mar 26, 2015

@evanpw you need to pass the axis as self._get_block_manager_axis(axis) which handles this. frames (only) are represented with inverted axes.

@evanpw
Copy link
Contributor Author

evanpw commented Mar 26, 2015

Ahh, that explains it.

jreback added a commit that referenced this pull request Apr 29, 2015
ENH: Add an axis parameter to DataFrame.diff
@jreback jreback merged commit a6ae1af into pandas-dev:master Apr 29, 2015
@jreback
Copy link
Contributor

jreback commented Apr 29, 2015

@evanpw thanks!

@evanpw evanpw deleted the diff_axis branch June 10, 2015 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design Compat pandas objects compatability with Numpy or Python functions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants