@pytest.mark.parametrize('structure, expected', [(tuple, pd.Series([(1, 1, 1), (3, 4, 4)], index=[1, 3], name='C')), (list, pd.Series([[1, 1, 1], [3, 4, 4]], index=[1, 3], name='C')), ((lambda x: tuple(x)), pd.Series([(1, 1, 1), (3, 4, 4)], index=[1, 3], name='C')), ((lambda x: list(x)), pd.Series([[1, 1, 1], [3, 4, 4]], index=[1, 3], name='C'))])
def test_agg_structs_series(structure, expected):
    df = pd.DataFrame({'A': [1, 1, 1, 3, 3, 3], 'B': [1, 1, 1, 4, 4, 4], 'C': [1, 1, 1, 3, 4, 4]})
    result = df.groupby('A')['C'].aggregate(structure)
    expected.index.name = 'A'
    tm.assert_series_equal(result, expected)
@pytest.mark.parametrize('structure, expected', [(tuple, pd.Series([(1, 1, 1), (3, 4, 4)], index=[1, 3], name='C')), (list, pd.Series([[1, 1, 1], [3, 4, 4]], index=[1, 3], name='C')), ((lambda x: tuple(x)), pd.Series([(1, 1, 1), (3, 4, 4)], index=[1, 3], name='C')), ((lambda x: list(x)), pd.Series([[1, 1, 1], [3, 4, 4]], index=[1, 3], name='C'))])
def test_agg_structs_series(structure, expected):
    df = pd.DataFrame({'A': [1, 1, 1, 3, 3, 3], 'B': [1, 1, 1, 4, 4, 4], 'C': [1, 1, 1, 3, 4, 4]})
    result = df.groupby('A')['C'].aggregate(structure)
    expected.index.name = 'A'
    tm.assert_series_equal(result, expected)