Python pandas.tseries.offsets.FY5253Quarter() Examples

The following are 25 code examples of pandas.tseries.offsets.FY5253Quarter(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pandas.tseries.offsets , or try the search function .
Example #1
Source File: test_fiscal.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_offset(self):
        offset = makeFY5253NearestEndMonthQuarter(1, startingMonth=8,
                                                  weekday=WeekDay.THU,
                                                  qtr_with_extra_week=4)

        MU = [datetime(2012, 5, 31),
              datetime(2012, 8, 30), datetime(2012, 11, 29),
              datetime(2013, 2, 28), datetime(2013, 5, 30)]

        date = MU[0] + relativedelta(days=-1)
        for expected in MU:
            assert_offset_equal(offset, date, expected)
            date = date + offset

        assert_offset_equal(offset,
                            datetime(2012, 5, 31),
                            datetime(2012, 8, 30))
        assert_offset_equal(offset,
                            datetime(2012, 5, 30),
                            datetime(2012, 5, 31))

        offset2 = FY5253Quarter(weekday=5, startingMonth=12, variation="last",
                                qtr_with_extra_week=4)

        assert_offset_equal(offset2,
                            datetime(2013, 1, 15),
                            datetime(2013, 3, 30)) 
Example #2
Source File: test_fiscal.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_fy5253qtr_onoffset_last():
    # GH#19036
    offset = FY5253Quarter(n=-2, qtr_with_extra_week=1,
                           startingMonth=7, variation="last", weekday=2)
    ts = Timestamp('2011-01-26 19:03:40.331096129+0200',
                   tz='Africa/Windhoek')
    slow = (ts + offset) - offset == ts
    fast = offset.onOffset(ts)
    assert fast == slow 
Example #3
Source File: test_fiscal.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_fy5253qtr_onoffset_nearest():
    # GH#19036
    ts = Timestamp('1985-09-02 23:57:46.232550356-0300',
                   tz='Atlantic/Bermuda')
    offset = FY5253Quarter(n=3, qtr_with_extra_week=1, startingMonth=2,
                           variation="nearest", weekday=0)
    fast = offset.onOffset(ts)
    slow = (ts + offset) - offset == ts
    assert fast == slow 
Example #4
Source File: test_fiscal.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_offset(self):
        offset = makeFY5253NearestEndMonthQuarter(1, startingMonth=8,
                                                  weekday=WeekDay.THU,
                                                  qtr_with_extra_week=4)

        MU = [datetime(2012, 5, 31),
              datetime(2012, 8, 30), datetime(2012, 11, 29),
              datetime(2013, 2, 28), datetime(2013, 5, 30)]

        date = MU[0] + relativedelta(days=-1)
        for expected in MU:
            assert_offset_equal(offset, date, expected)
            date = date + offset

        assert_offset_equal(offset,
                            datetime(2012, 5, 31),
                            datetime(2012, 8, 30))
        assert_offset_equal(offset,
                            datetime(2012, 5, 30),
                            datetime(2012, 5, 31))

        offset2 = FY5253Quarter(weekday=5, startingMonth=12, variation="last",
                                qtr_with_extra_week=4)

        assert_offset_equal(offset2,
                            datetime(2013, 1, 15),
                            datetime(2013, 3, 30)) 
Example #5
Source File: test_fiscal.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def makeFY5253NearestEndMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="nearest", **kwds) 
Example #6
Source File: test_fiscal.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def makeFY5253LastOfMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="last", **kwds) 
Example #7
Source File: test_fiscal.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_fy5253qtr_onoffset_last():
    # GH#19036
    offset = FY5253Quarter(n=-2, qtr_with_extra_week=1,
                           startingMonth=7, variation="last", weekday=2)
    ts = Timestamp('2011-01-26 19:03:40.331096129+0200',
                   tz='Africa/Windhoek')
    slow = (ts + offset) - offset == ts
    fast = offset.onOffset(ts)
    assert fast == slow 
Example #8
Source File: test_fiscal.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_fy5253qtr_onoffset_nearest():
    # GH#19036
    ts = Timestamp('1985-09-02 23:57:46.232550356-0300',
                   tz='Atlantic/Bermuda')
    offset = FY5253Quarter(n=3, qtr_with_extra_week=1, startingMonth=2,
                           variation="nearest", weekday=0)
    fast = offset.onOffset(ts)
    slow = (ts + offset) - offset == ts
    assert fast == slow 
Example #9
Source File: test_fiscal.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_offset(self):
        offset = makeFY5253NearestEndMonthQuarter(1, startingMonth=8,
                                                  weekday=WeekDay.THU,
                                                  qtr_with_extra_week=4)

        MU = [datetime(2012, 5, 31),
              datetime(2012, 8, 30), datetime(2012, 11, 29),
              datetime(2013, 2, 28), datetime(2013, 5, 30)]

        date = MU[0] + relativedelta(days=-1)
        for expected in MU:
            assert_offset_equal(offset, date, expected)
            date = date + offset

        assert_offset_equal(offset,
                            datetime(2012, 5, 31),
                            datetime(2012, 8, 30))
        assert_offset_equal(offset,
                            datetime(2012, 5, 30),
                            datetime(2012, 5, 31))

        offset2 = FY5253Quarter(weekday=5, startingMonth=12, variation="last",
                                qtr_with_extra_week=4)

        assert_offset_equal(offset2,
                            datetime(2013, 1, 15),
                            datetime(2013, 3, 30)) 
Example #10
Source File: test_fiscal.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def makeFY5253NearestEndMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="nearest", **kwds) 
Example #11
Source File: test_fiscal.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def makeFY5253LastOfMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="last", **kwds) 
Example #12
Source File: test_fiscal.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_fy5253qtr_onoffset_last():
    # GH#19036
    offset = FY5253Quarter(n=-2, qtr_with_extra_week=1,
                           startingMonth=7, variation="last", weekday=2)
    ts = Timestamp('2011-01-26 19:03:40.331096129+0200',
                   tz='Africa/Windhoek')
    slow = (ts + offset) - offset == ts
    fast = offset.onOffset(ts)
    assert fast == slow 
Example #13
Source File: test_fiscal.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_fy5253qtr_onoffset_nearest():
    # GH#19036
    ts = Timestamp('1985-09-02 23:57:46.232550356-0300',
                   tz='Atlantic/Bermuda')
    offset = FY5253Quarter(n=3, qtr_with_extra_week=1, startingMonth=2,
                           variation="nearest", weekday=0)
    fast = offset.onOffset(ts)
    slow = (ts + offset) - offset == ts
    assert fast == slow 
Example #14
Source File: test_fiscal.py    From recruit with Apache License 2.0 5 votes vote down vote up
def makeFY5253LastOfMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="last", **kwds) 
Example #15
Source File: test_fiscal.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def makeFY5253NearestEndMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="nearest", **kwds) 
Example #16
Source File: test_fiscal.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def makeFY5253LastOfMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="last", **kwds) 
Example #17
Source File: test_fiscal.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_fy5253qtr_onoffset_last():
    # GH#19036
    offset = FY5253Quarter(n=-2, qtr_with_extra_week=1,
                           startingMonth=7, variation="last", weekday=2)
    ts = Timestamp('2011-01-26 19:03:40.331096129+0200',
                   tz='Africa/Windhoek')
    slow = (ts + offset) - offset == ts
    fast = offset.onOffset(ts)
    assert fast == slow 
Example #18
Source File: test_fiscal.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_fy5253qtr_onoffset_nearest():
    # GH#19036
    ts = Timestamp('1985-09-02 23:57:46.232550356-0300',
                   tz='Atlantic/Bermuda')
    offset = FY5253Quarter(n=3, qtr_with_extra_week=1, startingMonth=2,
                           variation="nearest", weekday=0)
    fast = offset.onOffset(ts)
    slow = (ts + offset) - offset == ts
    assert fast == slow 
Example #19
Source File: test_fiscal.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_offset(self):
        offset = makeFY5253NearestEndMonthQuarter(1, startingMonth=8,
                                                  weekday=WeekDay.THU,
                                                  qtr_with_extra_week=4)

        MU = [datetime(2012, 5, 31),
              datetime(2012, 8, 30), datetime(2012, 11, 29),
              datetime(2013, 2, 28), datetime(2013, 5, 30)]

        date = MU[0] + relativedelta(days=-1)
        for expected in MU:
            assert_offset_equal(offset, date, expected)
            date = date + offset

        assert_offset_equal(offset,
                            datetime(2012, 5, 31),
                            datetime(2012, 8, 30))
        assert_offset_equal(offset,
                            datetime(2012, 5, 30),
                            datetime(2012, 5, 31))

        offset2 = FY5253Quarter(weekday=5, startingMonth=12, variation="last",
                                qtr_with_extra_week=4)

        assert_offset_equal(offset2,
                            datetime(2013, 1, 15),
                            datetime(2013, 3, 30)) 
Example #20
Source File: test_fiscal.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def makeFY5253NearestEndMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="nearest", **kwds) 
Example #21
Source File: test_fiscal.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def makeFY5253LastOfMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="last", **kwds) 
Example #22
Source File: test_fiscal.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_fy5253qtr_onoffset_last():
    # GH#19036
    offset = FY5253Quarter(n=-2, qtr_with_extra_week=1,
                           startingMonth=7, variation="last", weekday=2)
    ts = Timestamp('2011-01-26 19:03:40.331096129+0200',
                   tz='Africa/Windhoek')
    slow = (ts + offset) - offset == ts
    fast = offset.onOffset(ts)
    assert fast == slow 
Example #23
Source File: test_fiscal.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_fy5253qtr_onoffset_nearest():
    # GH#19036
    ts = Timestamp('1985-09-02 23:57:46.232550356-0300',
                   tz='Atlantic/Bermuda')
    offset = FY5253Quarter(n=3, qtr_with_extra_week=1, startingMonth=2,
                           variation="nearest", weekday=0)
    fast = offset.onOffset(ts)
    slow = (ts + offset) - offset == ts
    assert fast == slow 
Example #24
Source File: test_fiscal.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_offset(self):
        offset = makeFY5253NearestEndMonthQuarter(1, startingMonth=8,
                                                  weekday=WeekDay.THU,
                                                  qtr_with_extra_week=4)

        MU = [datetime(2012, 5, 31),
              datetime(2012, 8, 30), datetime(2012, 11, 29),
              datetime(2013, 2, 28), datetime(2013, 5, 30)]

        date = MU[0] + relativedelta(days=-1)
        for expected in MU:
            assert_offset_equal(offset, date, expected)
            date = date + offset

        assert_offset_equal(offset,
                            datetime(2012, 5, 31),
                            datetime(2012, 8, 30))
        assert_offset_equal(offset,
                            datetime(2012, 5, 30),
                            datetime(2012, 5, 31))

        offset2 = FY5253Quarter(weekday=5, startingMonth=12, variation="last",
                                qtr_with_extra_week=4)

        assert_offset_equal(offset2,
                            datetime(2013, 1, 15),
                            datetime(2013, 3, 30)) 
Example #25
Source File: test_fiscal.py    From recruit with Apache License 2.0 5 votes vote down vote up
def makeFY5253NearestEndMonthQuarter(*args, **kwds):
    return FY5253Quarter(*args, variation="nearest", **kwds)