当前位置: 首页>>代码示例>>Python>>正文


Python dtypes.DatetimeTZDtype类代码示例

本文整理汇总了Python中pandas.core.dtypes.dtypes.DatetimeTZDtype的典型用法代码示例。如果您正苦于以下问题:Python DatetimeTZDtype类的具体用法?Python DatetimeTZDtype怎么用?Python DatetimeTZDtype使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DatetimeTZDtype类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_construct_from_string_raises

    def test_construct_from_string_raises(self):
        with pytest.raises(TypeError, match="notatz"):
            DatetimeTZDtype.construct_from_string('datetime64[ns, notatz]')

        with pytest.raises(TypeError,
                           match="^Could not construct DatetimeTZDtype$"):
            DatetimeTZDtype.construct_from_string(['datetime64[ns, notatz]'])
开发者ID:johnnychiuchiu,项目名称:pandas,代码行数:7,代码来源:test_dtypes.py

示例2: test_construction_from_string

 def test_construction_from_string(self):
     result = DatetimeTZDtype.construct_from_string(
         'datetime64[ns, US/Eastern]')
     assert is_dtype_equal(self.dtype, result)
     msg = "Could not construct DatetimeTZDtype from 'foo'"
     with pytest.raises(TypeError, match=msg):
         DatetimeTZDtype.construct_from_string('foo')
开发者ID:chrish42,项目名称:pandas,代码行数:7,代码来源:test_dtypes.py

示例3: test_construction_from_string

 def test_construction_from_string(self):
     result = DatetimeTZDtype('datetime64[ns, US/Eastern]')
     assert is_dtype_equal(self.dtype, result)
     result = DatetimeTZDtype.construct_from_string(
         'datetime64[ns, US/Eastern]')
     assert is_dtype_equal(self.dtype, result)
     pytest.raises(TypeError,
                   lambda: DatetimeTZDtype.construct_from_string('foo'))
开发者ID:mficek,项目名称:pandas,代码行数:8,代码来源:test_dtypes.py

示例4: validate_tz_from_dtype

def validate_tz_from_dtype(dtype, tz):
    """
    If the given dtype is a DatetimeTZDtype, extract the implied
    tzinfo object from it and check that it does not conflict with the given
    tz.

    Parameters
    ----------
    dtype : dtype, str
    tz : None, tzinfo

    Returns
    -------
    tz : consensus tzinfo

    Raises
    ------
    ValueError : on tzinfo mismatch
    """
    if dtype is not None:
        try:
            dtype = DatetimeTZDtype.construct_from_string(dtype)
            dtz = getattr(dtype, 'tz', None)
            if dtz is not None:
                if tz is not None and not timezones.tz_compare(tz, dtz):
                    raise ValueError("cannot supply both a tz and a dtype"
                                     " with a tz")
                tz = dtz
        except TypeError:
            pass
    return tz
开发者ID:glyg,项目名称:pandas,代码行数:31,代码来源:datetimelike.py

示例5: test_is_dtype

 def test_is_dtype(self):
     assert not DatetimeTZDtype.is_dtype(None)
     assert DatetimeTZDtype.is_dtype(self.dtype)
     assert DatetimeTZDtype.is_dtype('datetime64[ns, US/Eastern]')
     assert not DatetimeTZDtype.is_dtype('foo')
     assert DatetimeTZDtype.is_dtype(DatetimeTZDtype('ns', 'US/Pacific'))
     assert not DatetimeTZDtype.is_dtype(np.float64)
开发者ID:mficek,项目名称:pandas,代码行数:7,代码来源:test_dtypes.py

示例6: test_is_dtype

 def test_is_dtype(self):
     self.assertFalse(DatetimeTZDtype.is_dtype(None))
     self.assertTrue(DatetimeTZDtype.is_dtype(self.dtype))
     self.assertTrue(DatetimeTZDtype.is_dtype('datetime64[ns, US/Eastern]'))
     self.assertFalse(DatetimeTZDtype.is_dtype('foo'))
     self.assertTrue(DatetimeTZDtype.is_dtype(DatetimeTZDtype(
         'ns', 'US/Pacific')))
     self.assertFalse(DatetimeTZDtype.is_dtype(np.float64))
开发者ID:tsdlovell,项目名称:pandas,代码行数:8,代码来源:test_dtypes.py

示例7: test_parser

 def test_parser(self, tz, constructor):
     # pr #11245
     dtz_str = '{con}[ns, {tz}]'.format(con=constructor, tz=tz)
     result = DatetimeTZDtype.construct_from_string(dtz_str)
     expected = DatetimeTZDtype('ns', tz)
     assert result == expected
开发者ID:changhiskhan,项目名称:pandas,代码行数:6,代码来源:test_dtypes.py

示例8: test_subclass

    def test_subclass(self):
        a = DatetimeTZDtype.construct_from_string('datetime64[ns, US/Eastern]')
        b = DatetimeTZDtype.construct_from_string('datetime64[ns, CET]')

        assert issubclass(type(a), type(a))
        assert issubclass(type(a), type(b))
开发者ID:changhiskhan,项目名称:pandas,代码行数:6,代码来源:test_dtypes.py

示例9: test_datetimetz_dtype

 def test_datetimetz_dtype(self, dtype):
     assert (com.pandas_dtype(dtype) ==
             DatetimeTZDtype.construct_from_string(dtype))
     assert com.pandas_dtype(dtype) == dtype
开发者ID:clham,项目名称:pandas,代码行数:4,代码来源:test_common.py

示例10: assert

    assert (not array_equivalent(m, n, strict_nan=False))


def test_array_equivalent_str():
    for dtype in ['O', 'S', 'U']:
        assert array_equivalent(np.array(['A', 'B'], dtype=dtype),
                                np.array(['A', 'B'], dtype=dtype))
        assert not array_equivalent(np.array(['A', 'B'], dtype=dtype),
                                    np.array(['A', 'X'], dtype=dtype))


@pytest.mark.parametrize('dtype, na_value', [
    # Datetime-like
    (np.dtype("M8[ns]"), NaT),
    (np.dtype("m8[ns]"), NaT),
    (DatetimeTZDtype.construct_from_string('datetime64[ns, US/Eastern]'), NaT),
    (PeriodDtype("M"), NaT),
    # Integer
    ('u1', 0), ('u2', 0), ('u4', 0), ('u8', 0),
    ('i1', 0), ('i2', 0), ('i4', 0), ('i8', 0),
    # Bool
    ('bool', False),
    # Float
    ('f2', np.nan), ('f4', np.nan), ('f8', np.nan),
    # Object
    ('O', np.nan),
    # Interval
    (IntervalDtype(), np.nan),
])
def test_na_value_for_dtype(dtype, na_value):
    result = na_value_for_dtype(dtype)
开发者ID:brianholland,项目名称:pandas,代码行数:31,代码来源:test_missing.py


注:本文中的pandas.core.dtypes.dtypes.DatetimeTZDtype类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。