Skip to content

Commit

Permalink
Add user function example
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonbb committed Apr 18, 2024
1 parent 9b0dcd7 commit f5ac739
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/nested_pandas/nestedframe/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,24 @@ def reduce(self, func, *args, **kwargs) -> pd.DataFrame:
-------
`NestedFrame`
`NestedFrame` with the results of the function applied to the columns of the frame.
Notes
-----
The recommend return value of func should be a `pd.Series` where the indices are the names of the
output columns in the dataframe returned by `reduce`.
Example User Function:
```
import pandas as pd
def my_sum(col1, col2):
return pd.Series(
[sum(col1), sum(col2)],
index=["sum_col1", "sum_col2"],
)
```
"""
# Parse through the initial args to determine the columns to apply the function to
requested_columns = []
Expand Down

0 comments on commit f5ac739

Please sign in to comment.