コード例 #1
0
 def dtype(self):
     return PeriodDtype.construct_from_string(self.freq)
コード例 #2
0
ファイル: period.py プロジェクト: clwater/lesson_python
 def dtype(self):
     return PeriodDtype.construct_from_string(self.freq)
コード例 #3
0
ファイル: test_dtypes.py プロジェクト: sunyuzheng/pandas
    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]')
コード例 #4
0
ファイル: test_dtypes.py プロジェクト: adrian-stepien/pandas
    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]')