| 3948 | |
| 3949 | @pytest.mark.parametrize("data_freq,divs1", [("B", False), ("D", True), ("h", True)]) |
| 3950 | def test_shift_with_freq_DatetimeIndex(data_freq, divs1): |
| 3951 | df = _compat.makeTimeDataFrame() |
| 3952 | df = df.set_index(_compat.makeDateIndex(30, freq=data_freq)) |
| 3953 | ddf = dd.from_pandas(df, npartitions=4) |
| 3954 | for freq, divs2 in [("s", True), ("W", False), (pd.Timedelta(10, unit="h"), True)]: |
| 3955 | for d, p in [(ddf, df), (ddf.A, df.A), (ddf.index, df.index)]: |
| 3956 | res = d.shift(2, freq=freq) |
| 3957 | assert_eq(res, p.shift(2, freq=freq)) |
| 3958 | assert res.known_divisions == divs2 |
| 3959 | # Index shifts also work with freq=None |
| 3960 | res = ddf.index.shift(2) |
| 3961 | assert_eq(res, df.index.shift(2)) |
| 3962 | assert res.known_divisions == divs1 |
| 3963 | |
| 3964 | |
| 3965 | @pytest.mark.parametrize("data_freq,divs", [("D", True), ("h", True)]) |