From f5ac739e3a3c2ba65f3a2863956b659375e3c961 Mon Sep 17 00:00:00 2001 From: Wilson Beebe Date: Thu, 18 Apr 2024 15:26:54 -0700 Subject: [PATCH] Add user function example --- src/nested_pandas/nestedframe/core.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/nested_pandas/nestedframe/core.py b/src/nested_pandas/nestedframe/core.py index d90fa61..c859da1 100644 --- a/src/nested_pandas/nestedframe/core.py +++ b/src/nested_pandas/nestedframe/core.py @@ -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 = []