Skip to content

Commit 442e071

Browse files
committed
TST: Added test_groupby_groups_in_BaseGrouper_with_BinGrouper
1 parent 8415f9b commit 442e071

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pandas/tests/groupby/test_groupby.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,6 +1864,20 @@ def test_groupby_groups_in_BaseGrouper():
18641864
assert result.groups == expected.groups
18651865

18661866

1867+
def test_groupby_groups_in_BaseGrouper_with_BinGrouper():
1868+
# GH 33132
1869+
# Test if DataFrame grouped with a pandas.Grouper and freq param has correct groups
1870+
mi = pd.MultiIndex.from_product(
1871+
[date_range(datetime.today(), periods=2), ["C", "D"]], names=["alpha", "beta"]
1872+
)
1873+
df = pd.DataFrame({"foo": [1, 2, 1, 2], "bar": [1, 2, 3, 4]}, index=mi)
1874+
result = df.groupby(["beta", pd.Grouper(level="alpha", freq="D")])
1875+
assert result.ngroups == len(result)
1876+
1877+
result = df.groupby([pd.Grouper(level="alpha", freq="D"), "beta"])
1878+
assert result.ngroups == len(result)
1879+
1880+
18671881
@pytest.mark.parametrize("group_name", ["x", ["x"]])
18681882
def test_groupby_axis_1(group_name):
18691883
# GH 27614

0 commit comments

Comments
 (0)