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

Add ability to apply a function row/columnwise on a dataframe or Series #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

seanboothm
Copy link

Add ability to apply a function row/columnwise on a dataframe or Series

@pf.register_series_or_dataframe_method(axis=1)
def total_diff(col, start_idx=0, end_idx=-1):
""" Return difference between the last and the first values per row/column"""
return col.iloc[end_idx] - col.iloc[start_idx]
Copy link
Author

@seanboothm seanboothm Mar 5, 2021

Choose a reason for hiding this comment

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

I know this is really not a great example of the need for register_series_or_dataframe_method, as total_diff could easily be vectorized. I do believe this function is beneficial in situations where the operation cannot be vectorized and must be completed column by column.

I am open to suggestions for a better example and will update the README once a better example is found.

Copy link
Member

@ericmjl ericmjl left a comment

Choose a reason for hiding this comment

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

Hi @seanboothm! Thank you for the effort taken on the PR. I think zach still might be embargoed by his company, so I'm going to take the liberty to approve first, and then I'll confer with him on his private email on what he thinks about the PR.

The only suggestion I have is pretty minor - I think the function name should be register_series_and_dataframe_method -- the relationship is an "and" relationship and not an "or" relationship. It's a small change though, so I didn't want it to be a blocker, thus I approved first.

@seanboothm
Copy link
Author

Sounds great! I agree register_series_and_dataframe_method makes more sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants