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


Python timezones.tz_compare方法代码示例

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


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

示例1: test_localized_at_time_between_time

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def test_localized_at_time_between_time(self, tzstr):
        from datetime import time
        tz = timezones.maybe_get_tz(tzstr)

        rng = date_range('4/16/2012', '5/1/2012', freq='H')
        ts = Series(np.random.randn(len(rng)), index=rng)

        ts_local = ts.tz_localize(tzstr)

        result = ts_local.at_time(time(10, 0))
        expected = ts.at_time(time(10, 0)).tz_localize(tzstr)
        tm.assert_series_equal(result, expected)
        assert timezones.tz_compare(result.index.tz, tz)

        t1, t2 = time(10, 0), time(11, 0)
        result = ts_local.between_time(t1, t2)
        expected = ts.between_time(t1, t2).tz_localize(tzstr)
        tm.assert_series_equal(result, expected)
        assert timezones.tz_compare(result.index.tz, tz) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_timezones.py

示例2: test_dti_tz_convert_utc_to_local_no_modify

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def test_dti_tz_convert_utc_to_local_no_modify(self, tz):
        rng = date_range('3/11/2012', '3/12/2012', freq='H', tz='utc')
        rng_eastern = rng.tz_convert(tz)

        # Values are unmodified
        tm.assert_numpy_array_equal(rng.asi8, rng_eastern.asi8)

        assert timezones.tz_compare(rng_eastern.tz, timezones.maybe_get_tz(tz)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:10,代码来源:test_timezones.py

示例3: test_dti_from_tzaware_datetime

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def test_dti_from_tzaware_datetime(self, tz):
        d = [datetime(2012, 8, 19, tzinfo=tz)]

        index = DatetimeIndex(d)
        assert timezones.tz_compare(index.tz, tz) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_timezones.py

示例4: test_dti_convert_tz_aware_datetime_datetime

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def test_dti_convert_tz_aware_datetime_datetime(self, tz):
        # GH#1581
        dates = [datetime(2000, 1, 1), datetime(2000, 1, 2),
                 datetime(2000, 1, 3)]

        dates_aware = [conversion.localize_pydatetime(x, tz) for x in dates]
        result = DatetimeIndex(dates_aware)
        assert timezones.tz_compare(result.tz, tz)

        converted = to_datetime(dates_aware, utc=True)
        ex_vals = np.array([Timestamp(x).value for x in dates_aware])
        tm.assert_numpy_array_equal(converted.asi8, ex_vals)
        assert converted.tz is pytz.utc 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:15,代码来源:test_timezones.py

示例5: test_series_tz_localize_empty

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def test_series_tz_localize_empty(self, tzstr):
        # GH#2248
        ser = Series()

        ser2 = ser.tz_localize('utc')
        assert ser2.index.tz == pytz.utc

        ser2 = ser.tz_localize(tzstr)
        timezones.tz_compare(ser2.index.tz, timezones.maybe_get_tz(tzstr))

    # -----------------------------------------------------------------
    # Series.tz_convert 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:14,代码来源:test_timezones.py

示例6: _infer_tz_from_endpoints

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def _infer_tz_from_endpoints(start, end, tz):  # pragma: no cover
    """
    If a timezone is not explicitly given via `tz`, see if one can
    be inferred from the `start` and `end` endpoints.  If more than one
    of these inputs provides a timezone, require that they all agree.

    Parameters
    ----------
    start : Timestamp
    end : Timestamp
    tz : tzinfo or None

    Returns
    -------
    tz : tzinfo or None

    Raises
    ------
    TypeError : if start and end timezones do not agree
    """
    try:
        inferred_tz = timezones.infer_tzinfo(start, end)
    except AssertionError:
        # infer_tzinfo raises AssertionError if passed mismatched timezones
        raise TypeError(
            "Start and end cannot both be tz-aware with different timezones"
        )

    inferred_tz = timezones.maybe_get_tz(inferred_tz)
    tz = timezones.maybe_get_tz(tz)

    if tz is not None and inferred_tz is not None:
        if not timezones.tz_compare(inferred_tz, tz):
            raise AssertionError("Inferred time zone not equal to passed time zone")

    elif inferred_tz is not None:
        tz = inferred_tz

    return tz 
开发者ID:mars-project,项目名称:mars,代码行数:41,代码来源:date_range.py

示例7: test_dti_convert_tz_aware_datetime_datetime

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import tz_compare [as 别名]
def test_dti_convert_tz_aware_datetime_datetime(self, tz):
        # GH#1581
        dates = [datetime(2000, 1, 1), datetime(2000, 1, 2),
                 datetime(2000, 1, 3)]

        dates_aware = [tslib._localize_pydatetime(x, tz) for x in dates]
        result = DatetimeIndex(dates_aware)
        assert timezones.tz_compare(result.tz, tz)

        converted = to_datetime(dates_aware, utc=True)
        ex_vals = np.array([Timestamp(x).value for x in dates_aware])
        tm.assert_numpy_array_equal(converted.asi8, ex_vals)
        assert converted.tz is pytz.utc 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:15,代码来源:test_timezones.py


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