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

Method test_factorize_period

pandas/tests/test_algos.py:181–196  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

179 tm.assert_index_equal(uniques, exp)
180
181 def test_factorize_period(self):
182 # period
183 v1 = Period("201302", freq="M")
184 v2 = Period("201303", freq="M")
185 x = Series([v1, v1, v1, v2, v2, v1])
186
187 # periods are not 'sorted' as they are converted back into an index
188 codes, uniques = algos.factorize(x)
189 exp = np.array([0, 0, 0, 1, 1, 0], dtype=np.intp)
190 tm.assert_numpy_array_equal(codes, exp)
191 tm.assert_index_equal(uniques, PeriodIndex([v1, v2]))
192
193 codes, uniques = algos.factorize(x, sort=True)
194 exp = np.array([0, 0, 0, 1, 1, 0], dtype=np.intp)
195 tm.assert_numpy_array_equal(codes, exp)
196 tm.assert_index_equal(uniques, PeriodIndex([v1, v2]))
197
198 def test_factorize_timedelta(self):
199 # GH 5986

Callers

nothing calls this directly

Calls 4

SeriesClass · 0.90
PeriodIndexClass · 0.90
factorizeMethod · 0.45
arrayMethod · 0.45

Tested by

no test coverage detected