Add ability to apply a function row/columnwise on a dataframe or Series#19
Add ability to apply a function row/columnwise on a dataframe or Series#19seanboothm wants to merge 2 commits into
Conversation
…es with register_series_or_dataframe_method
| @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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
Sounds great! I agree |
Add ability to apply a function row/columnwise on a dataframe or Series