Python pandas.tseries.offsets.YearEnd() Examples

The following are 14 code examples of pandas.tseries.offsets.YearEnd(). 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_libfrequencies.py    From vnpy_crypto with MIT License 7 votes vote down vote up
def test_is_superperiod_subperiod():

    # input validation
    assert not (is_superperiod(offsets.YearEnd(), None))
    assert not (is_subperiod(offsets.MonthEnd(), None))
    assert not (is_superperiod(None, offsets.YearEnd()))
    assert not (is_subperiod(None, offsets.MonthEnd()))
    assert not (is_superperiod(None, None))
    assert not (is_subperiod(None, None))

    assert (is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (is_superperiod(offsets.Second(), offsets.Milli()))
    assert (is_subperiod(offsets.Milli(), offsets.Second()))

    assert (is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (is_subperiod(offsets.Nano(), offsets.Micro())) 
Example #2
Source File: test_frequencies.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_freq_group(self):
        assert resolution.get_freq_group('A') == 1000
        assert resolution.get_freq_group('3A') == 1000
        assert resolution.get_freq_group('-1A') == 1000
        assert resolution.get_freq_group('A-JAN') == 1000
        assert resolution.get_freq_group('A-MAY') == 1000

        assert resolution.get_freq_group('Y') == 1000
        assert resolution.get_freq_group('3Y') == 1000
        assert resolution.get_freq_group('-1Y') == 1000
        assert resolution.get_freq_group('Y-JAN') == 1000
        assert resolution.get_freq_group('Y-MAY') == 1000

        assert resolution.get_freq_group(offsets.YearEnd()) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=1)) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=5)) == 1000

        assert resolution.get_freq_group('W') == 4000
        assert resolution.get_freq_group('W-MON') == 4000
        assert resolution.get_freq_group('W-FRI') == 4000
        assert resolution.get_freq_group(offsets.Week()) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=1)) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=5)) == 4000 
Example #3
Source File: test_frequencies.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_freq_group(self):
        assert resolution.get_freq_group('A') == 1000
        assert resolution.get_freq_group('3A') == 1000
        assert resolution.get_freq_group('-1A') == 1000
        assert resolution.get_freq_group('A-JAN') == 1000
        assert resolution.get_freq_group('A-MAY') == 1000

        assert resolution.get_freq_group('Y') == 1000
        assert resolution.get_freq_group('3Y') == 1000
        assert resolution.get_freq_group('-1Y') == 1000
        assert resolution.get_freq_group('Y-JAN') == 1000
        assert resolution.get_freq_group('Y-MAY') == 1000

        assert resolution.get_freq_group(offsets.YearEnd()) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=1)) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=5)) == 1000

        assert resolution.get_freq_group('W') == 4000
        assert resolution.get_freq_group('W-MON') == 4000
        assert resolution.get_freq_group('W-FRI') == 4000
        assert resolution.get_freq_group(offsets.Week()) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=1)) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=5)) == 4000 
Example #4
Source File: test_frequencies.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_freq_group(self):
        assert resolution.get_freq_group('A') == 1000
        assert resolution.get_freq_group('3A') == 1000
        assert resolution.get_freq_group('-1A') == 1000
        assert resolution.get_freq_group('A-JAN') == 1000
        assert resolution.get_freq_group('A-MAY') == 1000

        assert resolution.get_freq_group('Y') == 1000
        assert resolution.get_freq_group('3Y') == 1000
        assert resolution.get_freq_group('-1Y') == 1000
        assert resolution.get_freq_group('Y-JAN') == 1000
        assert resolution.get_freq_group('Y-MAY') == 1000

        assert resolution.get_freq_group(offsets.YearEnd()) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=1)) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=5)) == 1000

        assert resolution.get_freq_group('W') == 4000
        assert resolution.get_freq_group('W-MON') == 4000
        assert resolution.get_freq_group('W-FRI') == 4000
        assert resolution.get_freq_group(offsets.Week()) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=1)) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=5)) == 4000 
Example #5
Source File: test_frequencies.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_freq_group(self):
        assert frequencies.get_freq_group('A') == 1000
        assert frequencies.get_freq_group('3A') == 1000
        assert frequencies.get_freq_group('-1A') == 1000
        assert frequencies.get_freq_group('A-JAN') == 1000
        assert frequencies.get_freq_group('A-MAY') == 1000

        assert frequencies.get_freq_group('Y') == 1000
        assert frequencies.get_freq_group('3Y') == 1000
        assert frequencies.get_freq_group('-1Y') == 1000
        assert frequencies.get_freq_group('Y-JAN') == 1000
        assert frequencies.get_freq_group('Y-MAY') == 1000

        assert frequencies.get_freq_group(offsets.YearEnd()) == 1000
        assert frequencies.get_freq_group(offsets.YearEnd(month=1)) == 1000
        assert frequencies.get_freq_group(offsets.YearEnd(month=5)) == 1000

        assert frequencies.get_freq_group('W') == 4000
        assert frequencies.get_freq_group('W-MON') == 4000
        assert frequencies.get_freq_group('W-FRI') == 4000
        assert frequencies.get_freq_group(offsets.Week()) == 4000
        assert frequencies.get_freq_group(offsets.Week(weekday=1)) == 4000
        assert frequencies.get_freq_group(offsets.Week(weekday=5)) == 4000 
Example #6
Source File: test_frequencies.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_is_superperiod_subperiod():

    # input validation
    assert not (frequencies.is_superperiod(offsets.YearEnd(), None))
    assert not (frequencies.is_subperiod(offsets.MonthEnd(), None))
    assert not (frequencies.is_superperiod(None, offsets.YearEnd()))
    assert not (frequencies.is_subperiod(None, offsets.MonthEnd()))
    assert not (frequencies.is_superperiod(None, None))
    assert not (frequencies.is_subperiod(None, None))

    assert (frequencies.is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (frequencies.is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (frequencies.is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (frequencies.is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (frequencies.is_superperiod(offsets.Second(), offsets.Milli()))
    assert (frequencies.is_subperiod(offsets.Milli(), offsets.Second()))

    assert (frequencies.is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (frequencies.is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (frequencies.is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (frequencies.is_subperiod(offsets.Nano(), offsets.Micro())) 
Example #7
Source File: test_frequencies.py    From coffeegrindsize with MIT License 6 votes vote down vote up
def test_freq_group(self):
        assert resolution.get_freq_group('A') == 1000
        assert resolution.get_freq_group('3A') == 1000
        assert resolution.get_freq_group('-1A') == 1000
        assert resolution.get_freq_group('A-JAN') == 1000
        assert resolution.get_freq_group('A-MAY') == 1000

        assert resolution.get_freq_group('Y') == 1000
        assert resolution.get_freq_group('3Y') == 1000
        assert resolution.get_freq_group('-1Y') == 1000
        assert resolution.get_freq_group('Y-JAN') == 1000
        assert resolution.get_freq_group('Y-MAY') == 1000

        assert resolution.get_freq_group(offsets.YearEnd()) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=1)) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=5)) == 1000

        assert resolution.get_freq_group('W') == 4000
        assert resolution.get_freq_group('W-MON') == 4000
        assert resolution.get_freq_group('W-FRI') == 4000
        assert resolution.get_freq_group(offsets.Week()) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=1)) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=5)) == 4000 
Example #8
Source File: test_frequencies.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_freq_group(self):
        assert resolution.get_freq_group('A') == 1000
        assert resolution.get_freq_group('3A') == 1000
        assert resolution.get_freq_group('-1A') == 1000
        assert resolution.get_freq_group('A-JAN') == 1000
        assert resolution.get_freq_group('A-MAY') == 1000

        assert resolution.get_freq_group('Y') == 1000
        assert resolution.get_freq_group('3Y') == 1000
        assert resolution.get_freq_group('-1Y') == 1000
        assert resolution.get_freq_group('Y-JAN') == 1000
        assert resolution.get_freq_group('Y-MAY') == 1000

        assert resolution.get_freq_group(offsets.YearEnd()) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=1)) == 1000
        assert resolution.get_freq_group(offsets.YearEnd(month=5)) == 1000

        assert resolution.get_freq_group('W') == 4000
        assert resolution.get_freq_group('W-MON') == 4000
        assert resolution.get_freq_group('W-FRI') == 4000
        assert resolution.get_freq_group(offsets.Week()) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=1)) == 4000
        assert resolution.get_freq_group(offsets.Week(weekday=5)) == 4000 
Example #9
Source File: test_libfrequencies.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_is_superperiod_subperiod():

    # input validation
    assert not (is_superperiod(offsets.YearEnd(), None))
    assert not (is_subperiod(offsets.MonthEnd(), None))
    assert not (is_superperiod(None, offsets.YearEnd()))
    assert not (is_subperiod(None, offsets.MonthEnd()))
    assert not (is_superperiod(None, None))
    assert not (is_subperiod(None, None))

    assert (is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert (is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert (is_superperiod(offsets.Hour(), offsets.Minute()))
    assert (is_subperiod(offsets.Minute(), offsets.Hour()))

    assert (is_superperiod(offsets.Second(), offsets.Milli()))
    assert (is_subperiod(offsets.Milli(), offsets.Second()))

    assert (is_superperiod(offsets.Milli(), offsets.Micro()))
    assert (is_subperiod(offsets.Micro(), offsets.Milli()))

    assert (is_superperiod(offsets.Micro(), offsets.Nano()))
    assert (is_subperiod(offsets.Nano(), offsets.Micro())) 
Example #10
Source File: test_libfrequencies.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_get_rule_month():
    result = get_rule_month('W')
    assert (result == 'DEC')
    result = get_rule_month(offsets.Week())
    assert (result == 'DEC')

    result = get_rule_month('D')
    assert (result == 'DEC')
    result = get_rule_month(offsets.Day())
    assert (result == 'DEC')

    result = get_rule_month('Q')
    assert (result == 'DEC')
    result = get_rule_month(offsets.QuarterEnd(startingMonth=12))

    result = get_rule_month('Q-JAN')
    assert (result == 'JAN')
    result = get_rule_month(offsets.QuarterEnd(startingMonth=1))
    assert (result == 'JAN')

    result = get_rule_month('A-DEC')
    assert (result == 'DEC')
    result = get_rule_month('Y-DEC')
    assert (result == 'DEC')
    result = get_rule_month(offsets.YearEnd())
    assert (result == 'DEC')

    result = get_rule_month('A-MAY')
    assert (result == 'MAY')
    result = get_rule_month('Y-MAY')
    assert (result == 'MAY')
    result = get_rule_month(offsets.YearEnd(month=5))
    assert (result == 'MAY') 
Example #11
Source File: test_frequencies.py    From Computable with MIT License 5 votes vote down vote up
def test_is_superperiod_subperiod():
    assert(fmod.is_superperiod(offsets.YearEnd(), offsets.MonthEnd()))
    assert(fmod.is_subperiod(offsets.MonthEnd(), offsets.YearEnd()))

    assert(fmod.is_superperiod(offsets.Hour(), offsets.Minute()))
    assert(fmod.is_subperiod(offsets.Minute(), offsets.Hour())) 
Example #12
Source File: test_frequencies.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_get_rule_month():
    result = frequencies._get_rule_month('W')
    assert (result == 'DEC')
    result = frequencies._get_rule_month(offsets.Week())
    assert (result == 'DEC')

    result = frequencies._get_rule_month('D')
    assert (result == 'DEC')
    result = frequencies._get_rule_month(offsets.Day())
    assert (result == 'DEC')

    result = frequencies._get_rule_month('Q')
    assert (result == 'DEC')
    result = frequencies._get_rule_month(offsets.QuarterEnd(startingMonth=12))
    print(result == 'DEC')

    result = frequencies._get_rule_month('Q-JAN')
    assert (result == 'JAN')
    result = frequencies._get_rule_month(offsets.QuarterEnd(startingMonth=1))
    assert (result == 'JAN')

    result = frequencies._get_rule_month('A-DEC')
    assert (result == 'DEC')
    result = frequencies._get_rule_month('Y-DEC')
    assert (result == 'DEC')
    result = frequencies._get_rule_month(offsets.YearEnd())
    assert (result == 'DEC')

    result = frequencies._get_rule_month('A-MAY')
    assert (result == 'MAY')
    result = frequencies._get_rule_month('Y-MAY')
    assert (result == 'MAY')
    result = frequencies._get_rule_month(offsets.YearEnd(month=5))
    assert (result == 'MAY') 
Example #13
Source File: daycounts.py    From FinanceHub with MIT License 5 votes vote down vote up
def eoy(d, offset=0):
        """Unmodified end-of-year. Returns the last date of year for the
        same year as in date d

        The offset parameter represents the number of years that will be
        added (if offset > 0) or subtracted (if offset < 0) to input date d.
        This is especially useful for offset = -1, which gives you the EOY
        of previous year, for example.
        """
        d = to_datetime(d)
        # As in the case of the EOM, we leave the offset to a different
        # function (see comments of EOM function)
        return d + DateOffset(years=offset) + YearEnd(0) 
Example #14
Source File: test_libfrequencies.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_get_rule_month():
    result = get_rule_month('W')
    assert (result == 'DEC')
    result = get_rule_month(offsets.Week())
    assert (result == 'DEC')

    result = get_rule_month('D')
    assert (result == 'DEC')
    result = get_rule_month(offsets.Day())
    assert (result == 'DEC')

    result = get_rule_month('Q')
    assert (result == 'DEC')
    result = get_rule_month(offsets.QuarterEnd(startingMonth=12))

    result = get_rule_month('Q-JAN')
    assert (result == 'JAN')
    result = get_rule_month(offsets.QuarterEnd(startingMonth=1))
    assert (result == 'JAN')

    result = get_rule_month('A-DEC')
    assert (result == 'DEC')
    result = get_rule_month('Y-DEC')
    assert (result == 'DEC')
    result = get_rule_month(offsets.YearEnd())
    assert (result == 'DEC')

    result = get_rule_month('A-MAY')
    assert (result == 'MAY')
    result = get_rule_month('Y-MAY')
    assert (result == 'MAY')
    result = get_rule_month(offsets.YearEnd(month=5))
    assert (result == 'MAY')