From 7e3de8c90b68985233e412ad76b878ff3a76a9f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Osorio=20L=C3=B3pez?= Date: Thu, 20 Jan 2022 14:47:48 -0500 Subject: [PATCH] TST: Add test inconsistency in group by (#44803) --- pandas/tests/groupby/test_groupby.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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"))