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


Python timezones.dateutil_gettz方法代码示例

本文整理汇总了Python中pandas._libs.tslibs.timezones.dateutil_gettz方法的典型用法代码示例。如果您正苦于以下问题:Python timezones.dateutil_gettz方法的具体用法?Python timezones.dateutil_gettz怎么用?Python timezones.dateutil_gettz使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas._libs.tslibs.timezones的用法示例。


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

示例1: test_month_range_union_tz_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_month_range_union_tz_dateutil(self):
        from pandas._libs.tslibs.timezones import dateutil_gettz
        tz = dateutil_gettz('US/Eastern')

        early_start = datetime(2011, 1, 1)
        early_end = datetime(2011, 3, 1)

        late_start = datetime(2011, 3, 1)
        late_end = datetime(2011, 5, 1)

        early_dr = date_range(start=early_start, end=early_end, tz=tz,
                              freq=MonthEnd())
        late_dr = date_range(start=late_start, end=late_end, tz=tz,
                             freq=MonthEnd())

        early_dr.union(late_dr) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_setops.py

示例2: test_month_range_union_tz_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_month_range_union_tz_dateutil(self):
        tm._skip_if_windows_python_3()

        from pandas._libs.tslibs.timezones import dateutil_gettz
        tz = dateutil_gettz('US/Eastern')

        early_start = datetime(2011, 1, 1)
        early_end = datetime(2011, 3, 1)

        late_start = datetime(2011, 3, 1)
        late_end = datetime(2011, 5, 1)

        early_dr = date_range(start=early_start, end=early_end, tz=tz,
                              freq=MonthEnd())
        late_dr = date_range(start=late_start, end=late_end, tz=tz,
                             freq=MonthEnd())

        early_dr.union(late_dr) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:20,代码来源:test_setops.py

示例3: test_timestamp_tz_arg_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_timestamp_tz_arg_dateutil(self):
        from pandas._libs.tslibs.timezones import dateutil_gettz
        from pandas._libs.tslibs.timezones import maybe_get_tz
        for case in ['dateutil/Europe/Brussels', 'dateutil/Asia/Tokyo',
                     'dateutil/US/Pacific']:
            p = Period('1/1/2005', freq='M').to_timestamp(
                tz=maybe_get_tz(case))
            exp = Timestamp('1/1/2005', tz='UTC').tz_convert(case)
            assert p == exp
            assert p.tz == dateutil_gettz(case.split('/', 1)[1])
            assert p.tz == exp.tz

            p = Period('1/1/2005',
                       freq='M').to_timestamp(freq='3H', tz=maybe_get_tz(case))
            exp = Timestamp('1/1/2005', tz='UTC').tz_convert(case)
            assert p == exp
            assert p.tz == dateutil_gettz(case.split('/', 1)[1])
            assert p.tz == exp.tz 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:20,代码来源:test_period.py

示例4: test_date_range_timestamp_equiv_explicit_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_date_range_timestamp_equiv_explicit_dateutil(self):
        from pandas._libs.tslibs.timezones import dateutil_gettz as gettz

        rng = date_range('20090415', '20090519', tz=gettz('US/Eastern'))
        stamp = rng[0]

        ts = Timestamp('20090415', tz=gettz('US/Eastern'), freq='D')
        assert ts == stamp 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_date_range.py

示例5: test_getitem_setitem_datetime_tz_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_getitem_setitem_datetime_tz_dateutil():
    from dateutil.tz import tzutc
    from pandas._libs.tslibs.timezones import dateutil_gettz as gettz

    tz = lambda x: tzutc() if x == 'UTC' else gettz(
        x)  # handle special case for utc in dateutil

    from pandas import date_range

    N = 50

    # testing with timezone, GH #2785
    rng = date_range('1/1/1990', periods=N, freq='H',
                     tz='America/New_York')
    ts = Series(np.random.randn(N), index=rng)

    # also test Timestamp tz handling, GH #2789
    result = ts.copy()
    result["1990-01-01 09:00:00+00:00"] = 0
    result["1990-01-01 09:00:00+00:00"] = ts[4]
    assert_series_equal(result, ts)

    result = ts.copy()
    result["1990-01-01 03:00:00-06:00"] = 0
    result["1990-01-01 03:00:00-06:00"] = ts[4]
    assert_series_equal(result, ts)

    # repeat with datetimes
    result = ts.copy()
    result[datetime(1990, 1, 1, 9, tzinfo=tz('UTC'))] = 0
    result[datetime(1990, 1, 1, 9, tzinfo=tz('UTC'))] = ts[4]
    assert_series_equal(result, ts)

    result = ts.copy()
    result[datetime(1990, 1, 1, 3, tzinfo=tz('America/Chicago'))] = 0
    result[datetime(1990, 1, 1, 3, tzinfo=tz('America/Chicago'))] = ts[4]
    assert_series_equal(result, ts) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:39,代码来源:test_datetime.py

示例6: test_timestamp_to_datetime_explicit_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_timestamp_to_datetime_explicit_dateutil(self):
        stamp = Timestamp('20090415', tz=gettz('US/Eastern'), freq='D')
        dtval = stamp.to_pydatetime()
        assert stamp == dtval
        assert stamp.tzinfo == dtval.tzinfo 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_timestamp.py

示例7: test_to_timestamp_tz_arg_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_to_timestamp_tz_arg_dateutil(self, tzstr):
        tz = maybe_get_tz(tzstr)
        p = Period('1/1/2005', freq='M').to_timestamp(tz=tz)
        exp = Timestamp('1/1/2005', tz='UTC').tz_convert(tzstr)
        assert p == exp
        assert p.tz == dateutil_gettz(tzstr.split('/', 1)[1])
        assert p.tz == exp.tz

        p = Period('1/1/2005', freq='M').to_timestamp(freq='3H', tz=tz)
        exp = Timestamp('1/1/2005', tz='UTC').tz_convert(tzstr)
        assert p == exp
        assert p.tz == dateutil_gettz(tzstr.split('/', 1)[1])
        assert p.tz == exp.tz 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_period.py

示例8: test_timestamp_tz_arg_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_timestamp_tz_arg_dateutil(self, tzstr):
        from pandas._libs.tslibs.timezones import dateutil_gettz
        from pandas._libs.tslibs.timezones import maybe_get_tz
        tz = maybe_get_tz(tzstr)
        p = Period('1/1/2005', freq='M').to_timestamp(tz=tz)
        exp = Timestamp('1/1/2005', tz='UTC').tz_convert(tzstr)
        assert p == exp
        assert p.tz == dateutil_gettz(tzstr.split('/', 1)[1])
        assert p.tz == exp.tz

        p = Period('1/1/2005', freq='M').to_timestamp(freq='3H', tz=tz)
        exp = Timestamp('1/1/2005', tz='UTC').tz_convert(tzstr)
        assert p == exp
        assert p.tz == dateutil_gettz(tzstr.split('/', 1)[1])
        assert p.tz == exp.tz 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:17,代码来源:test_period.py

示例9: test_getitem_setitem_datetime_tz_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_getitem_setitem_datetime_tz_dateutil(self):
        from dateutil.tz import tzutc
        from pandas._libs.tslibs.timezones import dateutil_gettz as gettz

        tz = lambda x: tzutc() if x == 'UTC' else gettz(
            x)  # handle special case for utc in dateutil

        from pandas import date_range

        N = 50

        # testing with timezone, GH #2785
        rng = date_range('1/1/1990', periods=N, freq='H',
                         tz='America/New_York')
        ts = Series(np.random.randn(N), index=rng)

        # also test Timestamp tz handling, GH #2789
        result = ts.copy()
        result["1990-01-01 09:00:00+00:00"] = 0
        result["1990-01-01 09:00:00+00:00"] = ts[4]
        assert_series_equal(result, ts)

        result = ts.copy()
        result["1990-01-01 03:00:00-06:00"] = 0
        result["1990-01-01 03:00:00-06:00"] = ts[4]
        assert_series_equal(result, ts)

        # repeat with datetimes
        result = ts.copy()
        result[datetime(1990, 1, 1, 9, tzinfo=tz('UTC'))] = 0
        result[datetime(1990, 1, 1, 9, tzinfo=tz('UTC'))] = ts[4]
        assert_series_equal(result, ts)

        result = ts.copy()
        result[datetime(1990, 1, 1, 3, tzinfo=tz('America/Chicago'))] = 0
        result[datetime(1990, 1, 1, 3, tzinfo=tz('America/Chicago'))] = ts[4]
        assert_series_equal(result, ts) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:39,代码来源:test_indexing.py

示例10: test_timestamp_to_datetime_explicit_dateutil

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_timestamp_to_datetime_explicit_dateutil(self):
        tm._skip_if_windows_python_3()

        from pandas._libs.tslibs.timezones import dateutil_gettz as gettz
        rng = date_range('20090415', '20090519', tz=gettz('US/Eastern'))

        stamp = rng[0]
        dtval = stamp.to_pydatetime()
        assert stamp == dtval
        assert stamp.tzinfo == dtval.tzinfo 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:12,代码来源:test_timestamp.py

示例11: test_timestamp_tz_arg_dateutil_from_string

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import dateutil_gettz [as 别名]
def test_timestamp_tz_arg_dateutil_from_string(self):
        from pandas._libs.tslibs.timezones import dateutil_gettz
        p = Period('1/1/2005',
                   freq='M').to_timestamp(tz='dateutil/Europe/Brussels')
        assert p.tz == dateutil_gettz('Europe/Brussels') 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:7,代码来源:test_period.py


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