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


Python offsets.FY5253属性代码示例

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


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

示例1: test_bunched_yearends

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def test_bunched_yearends():
    # GH#14774 cases with two fiscal year-ends in the same calendar-year
    fy = FY5253(n=1, weekday=5, startingMonth=12, variation='nearest')
    dt = Timestamp('2004-01-01')
    assert fy.rollback(dt) == Timestamp('2002-12-28')
    assert (-fy).apply(dt) == Timestamp('2002-12-28')
    assert dt - fy == Timestamp('2002-12-28')

    assert fy.rollforward(dt) == Timestamp('2004-01-03')
    assert fy.apply(dt) == Timestamp('2004-01-03')
    assert fy + dt == Timestamp('2004-01-03')
    assert dt + fy == Timestamp('2004-01-03')

    # Same thing, but starting from a Timestamp in the previous year.
    dt = Timestamp('2003-12-31')
    assert fy.rollback(dt) == Timestamp('2002-12-28')
    assert (-fy).apply(dt) == Timestamp('2002-12-28')
    assert dt - fy == Timestamp('2002-12-28') 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:20,代码来源:test_fiscal.py

示例2: makeFY5253NearestEndMonth

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def makeFY5253NearestEndMonth(*args, **kwds):
    return FY5253(*args, variation="nearest", **kwds) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_fiscal.py

示例3: makeFY5253LastOfMonth

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def makeFY5253LastOfMonth(*args, **kwds):
    return FY5253(*args, variation="last", **kwds) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:4,代码来源:test_fiscal.py

示例4: test_get_year_end

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def test_get_year_end(self):
        assert (makeFY5253NearestEndMonth(
            startingMonth=8, weekday=WeekDay.SAT).get_year_end(
            datetime(2013, 1, 1)) == datetime(2013, 8, 31))
        assert (makeFY5253NearestEndMonth(
            startingMonth=8, weekday=WeekDay.SUN).get_year_end(
            datetime(2013, 1, 1)) == datetime(2013, 9, 1))
        assert (makeFY5253NearestEndMonth(
            startingMonth=8, weekday=WeekDay.FRI).get_year_end(
            datetime(2013, 1, 1)) == datetime(2013, 8, 30))

        offset_n = FY5253(weekday=WeekDay.TUE, startingMonth=12,
                          variation="nearest")
        assert (offset_n.get_year_end(datetime(2012, 1, 1)) ==
                datetime(2013, 1, 1))
        assert (offset_n.get_year_end(datetime(2012, 1, 10)) ==
                datetime(2013, 1, 1))

        assert (offset_n.get_year_end(datetime(2013, 1, 1)) ==
                datetime(2013, 12, 31))
        assert (offset_n.get_year_end(datetime(2013, 1, 2)) ==
                datetime(2013, 12, 31))
        assert (offset_n.get_year_end(datetime(2013, 1, 3)) ==
                datetime(2013, 12, 31))
        assert (offset_n.get_year_end(datetime(2013, 1, 10)) ==
                datetime(2013, 12, 31))

        JNJ = FY5253(n=1, startingMonth=12, weekday=6, variation="nearest")
        assert (JNJ.get_year_end(datetime(2006, 1, 1)) ==
                datetime(2006, 12, 31)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:32,代码来源:test_fiscal.py

示例5: test_fy5253_nearest_onoffset

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def test_fy5253_nearest_onoffset():
    # GH#18877 dates on the year-end but not normalized to midnight
    offset = FY5253(n=3, startingMonth=7, variation="nearest", weekday=2)
    ts = Timestamp('2032-07-28 00:12:59.035729419+0000', tz='Africa/Dakar')
    fast = offset.onOffset(ts)
    slow = (ts + offset) - offset == ts
    assert fast == slow 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:9,代码来源:test_fiscal.py

示例6: test_date_range_fy5252

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def test_date_range_fy5252(self):
        dr = date_range(start="2013-01-01",
                           periods=2,
                           freq=offsets.FY5253(startingMonth=1,
                                               weekday=3,
                                               variation="nearest"))
        self.assertEqual(dr[0], Timestamp('2013-01-31'))
        self.assertEqual(dr[1], Timestamp('2014-01-30')) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:test_timeseries.py

示例7: test_apply

# 需要导入模块: from pandas.tseries import offsets [as 别名]
# 或者: from pandas.tseries.offsets import FY5253 [as 别名]
def test_apply(self):
        date_seq_nem_8_sat = [datetime(2006, 9, 2), datetime(2007, 9, 1),
                              datetime(2008, 8, 30), datetime(2009, 8, 29),
                              datetime(2010, 8, 28), datetime(2011, 9, 3)]

        JNJ = [datetime(2005, 1, 2), datetime(2006, 1, 1),
               datetime(2006, 12, 31), datetime(2007, 12, 30),
               datetime(2008, 12, 28), datetime(2010, 1, 3),
               datetime(2011, 1, 2), datetime(2012, 1, 1),
               datetime(2012, 12, 30)]

        DEC_SAT = FY5253(n=-1, startingMonth=12, weekday=5,
                         variation="nearest")

        tests = [
            (makeFY5253NearestEndMonth(startingMonth=8,
                                       weekday=WeekDay.SAT),
             date_seq_nem_8_sat),
            (makeFY5253NearestEndMonth(n=1, startingMonth=8,
                                       weekday=WeekDay.SAT),
             date_seq_nem_8_sat),
            (makeFY5253NearestEndMonth(startingMonth=8, weekday=WeekDay.SAT),
             [datetime(2006, 9, 1)] + date_seq_nem_8_sat),
            (makeFY5253NearestEndMonth(n=1, startingMonth=8,
                                       weekday=WeekDay.SAT),
             [datetime(2006, 9, 3)] + date_seq_nem_8_sat[1:]),
            (makeFY5253NearestEndMonth(n=-1, startingMonth=8,
                                       weekday=WeekDay.SAT),
             list(reversed(date_seq_nem_8_sat))),
            (makeFY5253NearestEndMonth(n=1, startingMonth=12,
                                       weekday=WeekDay.SUN), JNJ),
            (makeFY5253NearestEndMonth(n=-1, startingMonth=12,
                                       weekday=WeekDay.SUN),
             list(reversed(JNJ))),
            (makeFY5253NearestEndMonth(n=1, startingMonth=12,
                                       weekday=WeekDay.SUN),
             [datetime(2005, 1, 2), datetime(2006, 1, 1)]),
            (makeFY5253NearestEndMonth(n=1, startingMonth=12,
                                       weekday=WeekDay.SUN),
             [datetime(2006, 1, 2), datetime(2006, 12, 31)]),
            (DEC_SAT, [datetime(2013, 1, 15), datetime(2012, 12, 29)])
        ]
        for test in tests:
            offset, data = test
            current = data[0]
            for datum in data[1:]:
                current = current + offset
                assert current == datum 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:50,代码来源:test_fiscal.py


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