def dtype(self): return PeriodDtype.construct_from_string(self.freq)
def test_construction_from_string(self): result = PeriodDtype('period[D]') self.assertTrue(is_dtype_equal(self.dtype, result)) result = PeriodDtype.construct_from_string('period[D]') self.assertTrue(is_dtype_equal(self.dtype, result)) with tm.assertRaises(TypeError): PeriodDtype.construct_from_string('foo') with tm.assertRaises(TypeError): PeriodDtype.construct_from_string('period[foo]') with tm.assertRaises(TypeError): PeriodDtype.construct_from_string('foo[D]') with tm.assertRaises(TypeError): PeriodDtype.construct_from_string('datetime64[ns]') with tm.assertRaises(TypeError): PeriodDtype.construct_from_string('datetime64[ns, US/Eastern]')