8000 PERF: fix regression in creation of resulting index in RollingGroupby by jorisvandenbossche · Pull Request #38057 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

PERF: fix regression in creation of resulting index in RollingGroupby #38057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Prev Previous commit
Next Next commit
update test_groupby_rolling_empty_frame test - change dtypes of expec…
…ted MI
  • Loading branch information
jorisvandenbossche committed Nov 30, 2020
commit 4546fd7da777306ae0c5c77ecf7a75b32ef11033
26 changes: 23 additions & 3 deletions pandas/tests/window/test_groupby.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import numpy as np
import pytest

from pandas import DataFrame, MultiIndex, Series, Timestamp, date_range, to_datetime
from pandas import (
DataFrame,
Index,
MultiIndex,
Series,
Timestamp,
date_range,
to_datetime,
)
import pandas._testing as tm
from pandas.api.indexers import BaseIndexer
from pandas.core.groupby.groupby import get_groupby
Expand Down Expand Up @@ -418,12 +426,24 @@ def test_groupby_rolling_empty_frame(self):
# GH 36197
expected = DataFrame({"s1": []})
result = expected.groupby("s1").rolling(window=1).sum()
expected.index = MultiIndex.from_tuples([], names=["s1", None])
# GH-38057 from_tupes gives empty object dtype, we now get float/int levels
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_tuples

# expected.index = MultiIndex.from_product([[], []], names=["s1", None])
expected.index = MultiIndex.from_product(
[Index([], dtype="float64"), Index([], dtype="int64")], names=["s1", None]
)
tm.assert_frame_equal(result, expected)

expected = DataFrame({"s1": [], "s2": []})
result = expected.groupby(["s1", "s2"]).rolling(window=1).sum()
expected.index = MultiIndex.from_tuples([], names=["s1", "s2", None])
# expected.index = MultiIndex.from_tuples([], names=["s1", "s2", None])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you remove the commented code :-<

expected.index = MultiIndex.from_product(
[
Index([], dtype="float64"),
Index([], dtype="float64"),
Index([], dtype="int64"),
],
names=["s1", "s2", None],
)
tm.assert_frame_equal(result, expected)

def test_groupby_rolling_string_index(self):
Expand Down
0