Skip to content

Commit

Permalink
sdks/python: test named aggregation
Browse files Browse the repository at this point in the history
In this commit, we test named aggregation to deferred
DataFrame groupby operation by passing None as function
and passing multiple kwargs aggregation functions on testing
columns.
  • Loading branch information
mohamedawnallah committed Feb 2, 2025
1 parent 5965581 commit 721f18e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions sdks/python/apache_beam/dataframe/frames_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2364,6 +2364,16 @@ def test_std_all_na(self):
self._run_test(lambda s: s.agg('std'), s)
self._run_test(lambda s: s.std(), s)

def test_df_agg_operations_on_columns(self):
self._run_test(
lambda df: df.groupby('group').agg(
mean_foo=('foo', lambda x: np.mean(x)),
median_bar=('bar', lambda x: np.median(x)),
sum_baz=('baz', 'sum'),
count_bool=('bool', 'count'),
),
GROUPBY_DF)

def test_std_mostly_na_with_ddof(self):
df = pd.DataFrame({
'one': [i if i % 8 == 0 else np.nan for i in range(8)],
Expand Down

0 comments on commit 721f18e

Please # to comment.