MCPcopy Create free account
hub / github.com/dask/dask / test_shift_with_freq_DatetimeIndex

Function test_shift_with_freq_DatetimeIndex

dask/dataframe/tests/test_dataframe.py:3950–3962  ·  view source on GitHub ↗
(data_freq, divs1)

Source from the content-addressed store, hash-verified

3948
3949@pytest.mark.parametrize("data_freq,divs1", [("B", False), ("D", True), ("h", True)])
3950def 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)])

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
set_indexMethod · 0.80
shiftMethod · 0.45

Tested by

no test coverage detected