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

Method test_to_period

pandas/tests/frame/methods/test_to_period.py:16–35  ·  view source on GitHub ↗
(self, frame_or_series)

Source from the content-addressed store, hash-verified

14
15class TestToPeriod:
16 def test_to_period(self, frame_or_series):
17 K = 5
18
19 dr = date_range("1/1/2000", "1/1/2001", freq="D")
20 obj = DataFrame(
21 np.random.default_rng(2).standard_normal((len(dr), K)),
22 index=dr,
23 columns=["A", "B", "C", "D", "E"],
24 )
25 obj["mix"] = "a"
26 obj = tm.get_obj(obj, frame_or_series)
27
28 pts = obj.to_period()
29 exp = obj.copy()
30 exp.index = period_range("1/1/2000", "1/1/2001")
31 tm.assert_equal(pts, exp)
32
33 pts = obj.to_period("M")
34 exp.index = exp.index.asfreq("M")
35 tm.assert_equal(pts, exp)
36
37 def test_to_period_without_freq(self, frame_or_series):
38 # GH#7606 without freq

Callers

nothing calls this directly

Calls 6

to_periodMethod · 0.95
date_rangeFunction · 0.90
DataFrameClass · 0.90
period_rangeFunction · 0.90
copyMethod · 0.45
asfreqMethod · 0.45

Tested by

no test coverage detected