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


Python frequencies.get_to_timestamp_base方法代码示例

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


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

示例1: test_get_to_timestamp_base

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_to_timestamp_base [as 别名]
def test_get_to_timestamp_base(self):
        tsb = frequencies.get_to_timestamp_base

        assert (tsb(frequencies.get_freq_code('D')[0]) ==
                frequencies.get_freq_code('D')[0])
        assert (tsb(frequencies.get_freq_code('W')[0]) ==
                frequencies.get_freq_code('D')[0])
        assert (tsb(frequencies.get_freq_code('M')[0]) ==
                frequencies.get_freq_code('D')[0])

        assert (tsb(frequencies.get_freq_code('S')[0]) ==
                frequencies.get_freq_code('S')[0])
        assert (tsb(frequencies.get_freq_code('T')[0]) ==
                frequencies.get_freq_code('S')[0])
        assert (tsb(frequencies.get_freq_code('H')[0]) ==
                frequencies.get_freq_code('S')[0]) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:test_frequencies.py

示例2: to_timestamp

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_to_timestamp_base [as 别名]
def to_timestamp(self, freq=None, how='start'):
        """
        Cast to DatetimeIndex

        Parameters
        ----------
        freq : string or DateOffset, optional
            Target frequency. The default is 'D' for week or longer,
            'S' otherwise
        how : {'s', 'e', 'start', 'end'}

        Returns
        -------
        DatetimeIndex
        """
        how = _validate_end_alias(how)

        if freq is None:
            base, mult = _gfc(self.freq)
            freq = frequencies.get_to_timestamp_base(base)
        else:
            freq = Period._maybe_convert_freq(freq)

        base, mult = _gfc(freq)
        new_data = self.asfreq(freq, how)

        new_data = period.periodarr_to_dt64arr(new_data._ndarray_values, base)
        return DatetimeIndex(new_data, freq='infer', name=self.name) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:30,代码来源:period.py

示例3: to_timestamp

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_to_timestamp_base [as 别名]
def to_timestamp(self, freq=None, how='start', tz=None):
        """
        Return the Timestamp representation of the Period at the target
        frequency at the specified end (how) of the Period

        Parameters
        ----------
        freq : string or DateOffset, default is 'D' if self.freq is week or
               longer and 'S' otherwise
            Target frequency
        how: str, default 'S' (start)
            'S', 'E'. Can be aliased as case insensitive
            'Start', 'Finish', 'Begin', 'End'

        Returns
        -------
        Timestamp
        """
        how = _validate_end_alias(how)

        if freq is None:
            base, mult = _gfc(self.freq)
            freq = _freq_mod.get_to_timestamp_base(base)

        base, mult = _gfc(freq)
        val = self.asfreq(freq, how)

        dt64 = tslib.period_ordinal_to_dt64(val.ordinal, base)
        return Timestamp(dt64, tz=tz) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:31,代码来源:period.py

示例4: to_timestamp

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_to_timestamp_base [as 别名]
def to_timestamp(self, freq=None, how='start'):
        """
        Cast to DatetimeIndex

        Parameters
        ----------
        freq : string or DateOffset, default 'D' for week or longer, 'S'
               otherwise
            Target frequency
        how : {'s', 'e', 'start', 'end'}

        Returns
        -------
        DatetimeIndex
        """
        how = _validate_end_alias(how)

        if freq is None:
            base, mult = _gfc(self.freq)
            freq = frequencies.get_to_timestamp_base(base)
        else:
            freq = Period._maybe_convert_freq(freq)

        base, mult = _gfc(freq)
        new_data = self.asfreq(freq, how)

        new_data = period.periodarr_to_dt64arr(new_data._values, base)
        return DatetimeIndex(new_data, freq='infer', name=self.name) 
开发者ID:nccgroup,项目名称:Splunking-Crime,代码行数:30,代码来源:period.py


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