diff --git a/pandas/tests/groupby/test_groupby.py b/pandas/tests/groupby/test_groupby.py index fb2b9f0632f0d..317b8b3090667 100644 --- a/pandas/tests/groupby/test_groupby.py +++ b/pandas/tests/groupby/test_groupby.py @@ -32,6 +32,20 @@ from pandas.core.groupby.base import maybe_normalize_deprecated_kernels +def test_group_by_copy(): + # GH#44803 + df = DataFrame( + { + "name": ["Alice", "Bob", "Carl"], + "age": [20, 21, 20], + } + ).set_index("name") + + grp_by_same_value = df.groupby(["age"]).apply(lambda group: group) + grp_by_copy = df.groupby(["age"]).apply(lambda group: group.copy()) + assert grp_by_same_value == grp_by_copy + + def test_repr(): # GH18203 result = repr(Grouper(key="A", level="B"))