Skip to content

Commit

Permalink
Add test for GH-37343
Browse files Browse the repository at this point in the history
  • Loading branch information
Japanuspus committed Nov 2, 2020
1 parent afd8491 commit e733ba4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pandas/tests/groupby/test_groupby_subclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ def test_groupby_preserves_subclass(obj, groupby_func):
tm.assert_series_equal(result1, result2)


def test_groupby_preserves_metadata():
# GH-37343
custom_df = tm.SubclassedDataFrame({"a": [1, 2, 3], "b": [1, 1, 2], "c": [7, 8, 9]})
assert "testattr" in custom_df._metadata
custom_df.testattr = "hello"
for _, group_df in custom_df.groupby("c"):
assert group_df.testattr == "hello"


@pytest.mark.parametrize("obj", [DataFrame, tm.SubclassedDataFrame])
def test_groupby_resample_preserves_subclass(obj):
# GH28330 -- preserve subclass through groupby.resample()
Expand Down

0 comments on commit e733ba4

Please sign in to comment.