MCPcopy
hub / github.com/pandas-dev/pandas / test_rolling_window_as_string

Function test_rolling_window_as_string

pandas/tests/window/test_rolling.py:638–657  ·  view source on GitHub ↗
(center)

Source from the content-addressed store, hash-verified

636
637
638def test_rolling_window_as_string(center):
639 # see gh-22590
640 date_today = datetime.now()
641 days = date_range(date_today, date_today + timedelta(365), freq="D")
642
643 data = np.ones(len(days))
644 df = DataFrame({"DateCol": days, "metric": data})
645
646 df.set_index("DateCol", inplace=True)
647 result = df.rolling(window="21D", min_periods=2, closed="left", center=center)[
648 "metric"
649 ].agg("max")
650
651 index = days.rename("DateCol")
652 index = index._with_freq(None)
653 expected_data = np.ones(len(days), dtype=np.float64)
654 if not center:
655 expected_data[:2] = np.nan
656 expected = Series(expected_data, index=index, name="metric")
657 tm.assert_series_equal(result, expected)
658
659
660def test_min_periods1():

Callers

nothing calls this directly

Calls 8

set_indexMethod · 0.95
date_rangeFunction · 0.90
DataFrameClass · 0.90
SeriesClass · 0.90
aggMethod · 0.45
rollingMethod · 0.45
renameMethod · 0.45
_with_freqMethod · 0.45

Tested by

no test coverage detected