Skip to content
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

[FEA] DataFrame diff #9604

Closed
beckernick opened this issue Nov 4, 2021 · 0 comments · Fixed by #9817
Closed

[FEA] DataFrame diff #9604

beckernick opened this issue Nov 4, 2021 · 0 comments · Fixed by #9817
Assignees
Labels
feature request New feature or request good first issue Good for newcomers Python Affects Python cuDF API.

Comments

@beckernick
Copy link
Member

For pandas compatibility, it would be nice to implement diff for DataFrames. This is currently implemented with a Numba kernel for Series and with the use of shift for Groupby.

The DataFrame.diff method calculates the difference of a Dataframe element compared with another element in the Dataframe, treating each column independently.

We should be able to remove the Numba implementation and instead rely on shift now that we have this feature.

import pandas as pddf = pd.DataFrame({'a': [1, 2, 3, 4, 5, 6],
                   'b': [1, 1, 2, 3, 5, 8],
                   'c': [1, 4, 9, 16, 25, 36]})
​
print(df, "\n")
print(df.diff(), "\n")
print(df.diff(periods=2))
   a  b   c
0  1  1   1
1  2  1   4
2  3  2   9
3  4  3  16
4  5  5  25
5  6  8  36 

     a    b     c
0  NaN  NaN   NaN
1  1.0  0.0   3.0
2  1.0  1.0   5.0
3  1.0  1.0   7.0
4  1.0  2.0   9.0
5  1.0  3.0  11.0 

     a    b     c
0  NaN  NaN   NaN
1  NaN  NaN   NaN
2  2.0  1.0   8.0
3  2.0  2.0  12.0
4  2.0  3.0  16.0
5  2.0  5.0  20.0
@beckernick beckernick added feature request New feature or request Python Affects Python cuDF API. labels Nov 4, 2021
@beckernick beckernick added the good first issue Good for newcomers label Nov 4, 2021
@skirui-source skirui-source self-assigned this Nov 30, 2021
@rapids-bot rapids-bot bot closed this as completed in #9817 Feb 5, 2022
rapids-bot bot pushed a commit that referenced this issue Feb 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request good first issue Good for newcomers Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants