Skip to content

Commit eeaf14d

Browse files

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

pandas/tests/groupby/test_grouping.py

+15
Original file line numberDiff line numberDiff line change
@@ -963,3 +963,18 @@ def test_grouping_string_repr(self):
963963
result = gr.grouper.groupings[0].__repr__()
964964
expected = "Grouping(('A', 'a'))"
965965
assert result == expected
966+
967+
968+
def test_groupby_iter_metadata():
969+
# GH-37343
970+
class SubclassedDataFrame2(DataFrame):
971+
_metadata = ["_added_property"]
972+
973+
@property
974+
def _constructor(self):
975+
return SubclassedDataFrame2
976+
977+
custom_df = SubclassedDataFrame2({"a": [1, 2, 3], "b": [1, 1, 2], "c": [7, 8, 9]})
978+
custom_df._added_property = "hello"
979+
for _, group_df in custom_df.groupby("c"):
980+
assert group_df._added_property == "hello"

0 commit comments

Comments
 (0)