Skip to content

Commit e733ba4

Browse files

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pandas/tests/groupby/test_groupby_subclass.py

+9
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ def test_groupby_preserves_subclass(obj, groupby_func):
5151
tm.assert_series_equal(result1, result2)
5252

5353

54+
def test_groupby_preserves_metadata():
55+
# GH-37343
56+
custom_df = tm.SubclassedDataFrame({"a": [1, 2, 3], "b": [1, 1, 2], "c": [7, 8, 9]})
57+
assert "testattr" in custom_df._metadata
58+
custom_df.testattr = "hello"
59+
for _, group_df in custom_df.groupby("c"):
60+
assert group_df.testattr == "hello"
61+
62+
5463
@pytest.mark.parametrize("obj", [DataFrame, tm.SubclassedDataFrame])
5564
def test_groupby_resample_preserves_subclass(obj):
5665
# GH28330 -- preserve subclass through groupby.resample()

0 commit comments

Comments
 (0)