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


Python timezones.get_timezone方法代码示例

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


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

示例1: _multi_index_to_records

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def _multi_index_to_records(index, empty_index):
    # array of tuples to numpy cols. copy copy copy
    if not empty_index:
        ix_vals = list(map(np.array, [index.get_level_values(i) for i in range(index.nlevels)]))
    else:
        # empty multi index has no size, create empty arrays for recarry.
        ix_vals = [np.array([]) for n in index.names]
    index_names = list(index.names)
    count = 0
    for i, n in enumerate(index_names):
        if n is None:
            index_names[i] = 'level_%d' % count
            count += 1
            log.info("Level in MultiIndex has no name, defaulting to %s" % index_names[i])
    index_tz = [get_timezone(i.tz) if isinstance(i, DatetimeIndex) else None for i in index.levels]
    return ix_vals, index_names, index_tz 
开发者ID:man-group,项目名称:arctic,代码行数:18,代码来源:numpy_records.py

示例2: _index_to_records

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def _index_to_records(self, df):
        metadata = {}
        index = df.index
        index_tz = None

        if isinstance(index, MultiIndex):
            ix_vals, index_names, index_tz = _multi_index_to_records(index, len(df) == 0)
        else:
            ix_vals = [index.values]
            index_names = list(index.names)
            if index_names[0] is None:
                index_names = ['index']
                log.info("Index has no name, defaulting to 'index'")
            if isinstance(index, DatetimeIndex) and index.tz is not None:
                index_tz = get_timezone(index.tz)

        if index_tz is not None:
            metadata['index_tz'] = index_tz
        metadata['index'] = index_names

        return index_names, ix_vals, metadata 
开发者ID:man-group,项目名称:arctic,代码行数:23,代码来源:numpy_records.py

示例3: test_utc_z_designator

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def test_utc_z_designator(self):
        assert get_timezone(Timestamp('2014-11-02 01:00Z').tzinfo) is utc 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_timestamp.py

示例4: _get_tz

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def _get_tz(tz):
    """ for a tz-aware type, return an encoded zone """
    zone = timezones.get_timezone(tz)
    if zone is None:
        zone = tz.utcoffset().total_seconds()
    return zone 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:8,代码来源:pytables.py

示例5: _set_tz

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def _set_tz(values, tz, preserve_UTC=False, coerce=False):
    """
    coerce the values to a DatetimeIndex if tz is set
    preserve the input shape if possible

    Parameters
    ----------
    values : ndarray
    tz : string/pickled tz object
    preserve_UTC : boolean,
        preserve the UTC of the result
    coerce : if we do not have a passed timezone, coerce to M8[ns] ndarray
    """
    if tz is not None:
        name = getattr(values, 'name', None)
        values = values.ravel()
        tz = timezones.get_timezone(_ensure_decoded(tz))
        values = DatetimeIndex(values, name=name)
        if values.tz is None:
            values = values.tz_localize('UTC').tz_convert(tz)
        if preserve_UTC:
            if tz == 'UTC':
                values = list(values)
    elif coerce:
        values = np.asarray(values, dtype='M8[ns]')

    return values 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:29,代码来源:pytables.py

示例6: test_utc_z_designator

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def test_utc_z_designator(self):
        assert get_timezone(Timestamp('2014-11-02 01:00Z').tzinfo) == 'UTC' 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:4,代码来源:test_timestamp.py

示例7: _timezone

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def _timezone(self):
        """ Comparable timezone both for pytz / dateutil"""
        return timezones.get_timezone(self.tzinfo) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:5,代码来源:datetimes.py

示例8: _has_same_tz

# 需要导入模块: from pandas._libs.tslibs import timezones [as 别名]
# 或者: from pandas._libs.tslibs.timezones import get_timezone [as 别名]
def _has_same_tz(self, other):
        zzone = self._timezone

        # vzone sholdn't be None if value is non-datetime like
        if isinstance(other, np.datetime64):
            # convert to Timestamp as np.datetime64 doesn't have tz attr
            other = Timestamp(other)
        vzone = timezones.get_timezone(getattr(other, 'tzinfo', '__no_tz__'))
        return zzone == vzone 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:11,代码来源:datetimes.py


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