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


Python Period.to_timestamp方法代码示例

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


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

示例1: Properties

# 需要导入模块: from pandas import Period [as 别名]
# 或者: from pandas.Period import to_timestamp [as 别名]
class Properties(object):
    def setup(self):
        self.per = Period('2017-09-06 08:28', freq='min')

    def time_year(self):
        self.per.year

    def time_month(self):
        self.per.month

    def time_day(self):
        self.per.day

    def time_hour(self):
        self.per.hour

    def time_minute(self):
        self.per.minute

    def time_second(self):
        self.per.second

    def time_is_leap_year(self):
        self.per.is_leap_year

    def time_quarter(self):
        self.per.quarter

    def time_qyear(self):
        self.per.qyear

    def time_week(self):
        self.per.week

    def time_daysinmonth(self):
        self.per.daysinmonth

    def time_dayofweek(self):
        self.per.dayofweek

    def time_dayofyear(self):
        self.per.dayofyear

    def time_start_time(self):
        self.per.start_time

    def time_end_time(self):
        self.per.end_time

    def time_to_timestamp():
        self.per.to_timestamp()

    def time_now():
        self.per.now()

    def time_asfreq():
        self.per.asfreq('A')
开发者ID:Axik,项目名称:pandas,代码行数:59,代码来源:period.py

示例2: test_period_cons_quarterly

# 需要导入模块: from pandas import Period [as 别名]
# 或者: from pandas.Period import to_timestamp [as 别名]
    def test_period_cons_quarterly(self):
        # bugs in scikits.timeseries
        for month in MONTHS:
            freq = 'Q-%s' % month
            exp = Period('1989Q3', freq=freq)
            assert '1989Q3' in str(exp)
            stamp = exp.to_timestamp('D', how='end')
            p = Period(stamp, freq=freq)
            assert p == exp

            stamp = exp.to_timestamp('3D', how='end')
            p = Period(stamp, freq=freq)
            assert p == exp
开发者ID:MichaelWS,项目名称:pandas,代码行数:15,代码来源:test_period.py

示例3: PeriodUnaryMethods

# 需要导入模块: from pandas import Period [as 别名]
# 或者: from pandas.Period import to_timestamp [as 别名]
class PeriodUnaryMethods(object):
    params = ['M', 'min']
    param_names = ['freq']

    def setup(self, freq):
        self.per = Period('2012-06-01', freq=freq)

    def time_to_timestamp(self, freq):
        self.per.to_timestamp()

    def time_now(self, freq):
        self.per.now(freq)

    def time_asfreq(self, freq):
        self.per.asfreq('A')
开发者ID:Xbar,项目名称:pandas,代码行数:17,代码来源:period.py

示例4: test_period_cons_annual

# 需要导入模块: from pandas import Period [as 别名]
# 或者: from pandas.Period import to_timestamp [as 别名]
 def test_period_cons_annual(self):
     # bugs in scikits.timeseries
     for month in MONTHS:
         freq = 'A-%s' % month
         exp = Period('1989', freq=freq)
         stamp = exp.to_timestamp('D', how='end') + timedelta(days=30)
         p = Period(stamp, freq=freq)
         assert p == exp + 1
         assert isinstance(p, Period)
开发者ID:MichaelWS,项目名称:pandas,代码行数:11,代码来源:test_period.py

示例5: test_to_timestamp_out_of_bounds

# 需要导入模块: from pandas import Period [as 别名]
# 或者: from pandas.Period import to_timestamp [as 别名]
 def test_to_timestamp_out_of_bounds(self):
     # GH#19643, currently gives Timestamp('1754-08-30 22:43:41.128654848')
     per = Period('0001-01-01', freq='B')
     with pytest.raises(OutOfBoundsDatetime):
         per.to_timestamp()
开发者ID:DusanMilunovic,项目名称:pandas,代码行数:7,代码来源:test_asfreq.py

示例6: test_to_timestamp

# 需要导入模块: from pandas import Period [as 别名]
# 或者: from pandas.Period import to_timestamp [as 别名]
    def test_to_timestamp(self):
        p = Period('1982', freq='A')
        start_ts = p.to_timestamp(how='S')
        aliases = ['s', 'StarT', 'BEGIn']
        for a in aliases:
            assert start_ts == p.to_timestamp('D', how=a)
            # freq with mult should not affect to the result
            assert start_ts == p.to_timestamp('3D', how=a)

        end_ts = p.to_timestamp(how='E')
        aliases = ['e', 'end', 'FINIsH']
        for a in aliases:
            assert end_ts == p.to_timestamp('D', how=a)
            assert end_ts == p.to_timestamp('3D', how=a)

        from_lst = ['A', 'Q', 'M', 'W', 'B', 'D', 'H', 'Min', 'S']

        def _ex(p):
            return Timestamp((p + 1).start_time.value - 1)

        for i, fcode in enumerate(from_lst):
            p = Period('1982', freq=fcode)
            result = p.to_timestamp().to_period(fcode)
            assert result == p

            assert p.start_time == p.to_timestamp(how='S')

            assert p.end_time == _ex(p)

        # Frequency other than daily

        p = Period('1985', freq='A')

        result = p.to_timestamp('H', how='end')
        expected = datetime(1985, 12, 31, 23)
        assert result == expected
        result = p.to_timestamp('3H', how='end')
        assert result == expected

        result = p.to_timestamp('T', how='end')
        expected = datetime(1985, 12, 31, 23, 59)
        assert result == expected
        result = p.to_timestamp('2T', how='end')
        assert result == expected

        result = p.to_timestamp(how='end')
        expected = datetime(1985, 12, 31)
        assert result == expected

        expected = datetime(1985, 1, 1)
        result = p.to_timestamp('H', how='start')
        assert result == expected
        result = p.to_timestamp('T', how='start')
        assert result == expected
        result = p.to_timestamp('S', how='start')
        assert result == expected
        result = p.to_timestamp('3H', how='start')
        assert result == expected
        result = p.to_timestamp('5S', how='start')
        assert result == expected
开发者ID:MichaelWS,项目名称:pandas,代码行数:62,代码来源:test_period.py


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