()
| 63 | |
| 64 | |
| 65 | def test_apply_iteration(): |
| 66 | # #2300 |
| 67 | N = 1000 |
| 68 | ind = date_range(start="2000-01-01", freq="D", periods=N) |
| 69 | df = DataFrame({"open": 1, "close": 2}, index=ind) |
| 70 | tg = Grouper(freq="ME") |
| 71 | |
| 72 | grouper, _ = tg._get_grouper(df) |
| 73 | |
| 74 | # Errors |
| 75 | grouped = df.groupby(grouper, group_keys=False) |
| 76 | |
| 77 | def f(df): |
| 78 | return df["close"] / df["open"] |
| 79 | |
| 80 | # it works! |
| 81 | result = grouped.apply(f) |
| 82 | tm.assert_index_equal(result.index, df.index) |
| 83 | |
| 84 | |
| 85 | @pytest.mark.parametrize( |
nothing calls this directly
no test coverage detected