(self)
| 973 | df.groupby("c").rolling(on="t", window="3s") |
| 974 | |
| 975 | def test_groupby_monotonic(self): |
| 976 | # GH 15130 |
| 977 | # we don't need to validate monotonicity when grouping |
| 978 | |
| 979 | # GH 43909 we should raise an error here to match |
| 980 | # behaviour of non-groupby rolling. |
| 981 | |
| 982 | data = [ |
| 983 | ["David", "1/1/2015", 100], |
| 984 | ["David", "1/5/2015", 500], |
| 985 | ["David", "5/30/2015", 50], |
| 986 | ["David", "7/25/2015", 50], |
| 987 | ["Ryan", "1/4/2014", 100], |
| 988 | ["Ryan", "1/19/2015", 500], |
| 989 | ["Ryan", "3/31/2016", 50], |
| 990 | ["Joe", "7/1/2015", 100], |
| 991 | ["Joe", "9/9/2015", 500], |
| 992 | ["Joe", "10/15/2015", 50], |
| 993 | ] |
| 994 | |
| 995 | df = DataFrame(data=data, columns=["name", "date", "amount"]) |
| 996 | df["date"] = to_datetime(df["date"]) |
| 997 | df = df.sort_values("date") |
| 998 | |
| 999 | expected = ( |
| 1000 | df.set_index("date") |
| 1001 | .groupby("name") |
| 1002 | .apply(lambda x: x.rolling("180D")["amount"].sum()) |
| 1003 | ) |
| 1004 | result = df.groupby("name").rolling("180D", on="date")["amount"].sum() |
| 1005 | tm.assert_series_equal(result, expected) |
| 1006 | |
| 1007 | def test_datelike_on_monotonic_within_each_group(self): |
| 1008 | # GH 13966 (similar to #15130, closed by #15175) |
nothing calls this directly
no test coverage detected