Python pandas.tseries.frequencies.get_offset() Examples

The following are 30 code examples of pandas.tseries.frequencies.get_offset(). 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.frequencies , or try the search function .
Example #1
Source File: test_offsets.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_get_offset():
    with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
        get_offset('gibberish')
    with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
        get_offset('QS-JAN-B')

    pairs = [
        ('B', BDay()), ('b', BDay()), ('bm', BMonthEnd()),
        ('Bm', BMonthEnd()), ('W-MON', Week(weekday=0)),
        ('W-TUE', Week(weekday=1)), ('W-WED', Week(weekday=2)),
        ('W-THU', Week(weekday=3)), ('W-FRI', Week(weekday=4))]

    for name, expected in pairs:
        offset = get_offset(name)
        assert offset == expected, ("Expected %r to yield %r (actual: %r)" %
                                    (name, expected, offset)) 
Example #2
Source File: test_frequencies.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_legacy_offset_warnings(self):
        freqs = ['WEEKDAY', 'EOM', 'W@MON', 'W@TUE', 'W@WED', 'W@THU',
                 'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
                 'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
                 'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
                 'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
                 'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
                 'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
                 'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
                 'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
                 'WOM@4FRI']

        msg = _INVALID_FREQ_ERROR
        for freq in freqs:
            with tm.assert_raises_regex(ValueError, msg):
                frequencies.get_offset(freq)

            with tm.assert_raises_regex(ValueError, msg):
                date_range('2011-01-01', periods=5, freq=freq) 
Example #3
Source File: test_offsets.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_get_offset():
    with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
        get_offset('gibberish')
    with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
        get_offset('QS-JAN-B')

    pairs = [
        ('B', BDay()), ('b', BDay()), ('bm', BMonthEnd()),
        ('Bm', BMonthEnd()), ('W-MON', Week(weekday=0)),
        ('W-TUE', Week(weekday=1)), ('W-WED', Week(weekday=2)),
        ('W-THU', Week(weekday=3)), ('W-FRI', Week(weekday=4))]

    for name, expected in pairs:
        offset = get_offset(name)
        assert offset == expected, ("Expected %r to yield %r (actual: %r)" %
                                    (name, expected, offset)) 
Example #4
Source File: test_frequencies.py    From coffeegrindsize with MIT License 6 votes vote down vote up
def test_legacy_offset_warnings(self):
        freqs = ['WEEKDAY', 'EOM', 'W@MON', 'W@TUE', 'W@WED', 'W@THU',
                 'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
                 'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
                 'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
                 'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
                 'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
                 'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
                 'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
                 'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
                 'WOM@4FRI']

        msg = INVALID_FREQ_ERR_MSG
        for freq in freqs:
            with pytest.raises(ValueError, match=msg):
                frequencies.get_offset(freq)

            with pytest.raises(ValueError, match=msg):
                date_range('2011-01-01', periods=5, freq=freq) 
Example #5
Source File: test_offsets.py    From coffeegrindsize with MIT License 6 votes vote down vote up
def test_get_offset():
    with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
        get_offset('gibberish')
    with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
        get_offset('QS-JAN-B')

    pairs = [
        ('B', BDay()), ('b', BDay()), ('bm', BMonthEnd()),
        ('Bm', BMonthEnd()), ('W-MON', Week(weekday=0)),
        ('W-TUE', Week(weekday=1)), ('W-WED', Week(weekday=2)),
        ('W-THU', Week(weekday=3)), ('W-FRI', Week(weekday=4))]

    for name, expected in pairs:
        offset = get_offset(name)
        assert offset == expected, ("Expected %r to yield %r (actual: %r)" %
                                    (name, expected, offset)) 
Example #6
Source File: test_frequencies.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_legacy_offset_warnings(self):
        freqs = ['WEEKDAY', 'EOM', 'W@MON', 'W@TUE', 'W@WED', 'W@THU',
                 'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
                 'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
                 'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
                 'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
                 'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
                 'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
                 'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
                 'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
                 'WOM@4FRI']

        msg = frequencies._INVALID_FREQ_ERROR
        for freq in freqs:
            with tm.assert_raises_regex(ValueError, msg):
                frequencies.get_offset(freq)

            with tm.assert_raises_regex(ValueError, msg):
                date_range('2011-01-01', periods=5, freq=freq) 
Example #7
Source File: test_frequencies.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_legacy_offset_warnings(self):
        freqs = ['WEEKDAY', 'EOM', 'W@MON', 'W@TUE', 'W@WED', 'W@THU',
                 'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
                 'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
                 'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
                 'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
                 'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
                 'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
                 'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
                 'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
                 'WOM@4FRI']

        msg = INVALID_FREQ_ERR_MSG
        for freq in freqs:
            with pytest.raises(ValueError, match=msg):
                frequencies.get_offset(freq)

            with pytest.raises(ValueError, match=msg):
                date_range('2011-01-01', periods=5, freq=freq) 
Example #8
Source File: test_offsets.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_get_offset():
    with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
        get_offset('gibberish')
    with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
        get_offset('QS-JAN-B')

    pairs = [
        ('B', BDay()), ('b', BDay()), ('bm', BMonthEnd()),
        ('Bm', BMonthEnd()), ('W-MON', Week(weekday=0)),
        ('W-TUE', Week(weekday=1)), ('W-WED', Week(weekday=2)),
        ('W-THU', Week(weekday=3)), ('W-FRI', Week(weekday=4))]

    for name, expected in pairs:
        offset = get_offset(name)
        assert offset == expected, ("Expected %r to yield %r (actual: %r)" %
                                    (name, expected, offset)) 
Example #9
Source File: test_frequencies.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_legacy_offset_warnings(self):
        freqs = ['WEEKDAY', 'EOM', 'W@MON', 'W@TUE', 'W@WED', 'W@THU',
                 'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
                 'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
                 'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
                 'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
                 'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
                 'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
                 'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
                 'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
                 'WOM@4FRI']

        msg = _INVALID_FREQ_ERROR
        for freq in freqs:
            with tm.assert_raises_regex(ValueError, msg):
                frequencies.get_offset(freq)

            with tm.assert_raises_regex(ValueError, msg):
                date_range('2011-01-01', periods=5, freq=freq) 
Example #10
Source File: test_offsets.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_get_offset():
    with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
        get_offset('gibberish')
    with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
        get_offset('QS-JAN-B')

    pairs = [
        ('B', BDay()), ('b', BDay()), ('bm', BMonthEnd()),
        ('Bm', BMonthEnd()), ('W-MON', Week(weekday=0)),
        ('W-TUE', Week(weekday=1)), ('W-WED', Week(weekday=2)),
        ('W-THU', Week(weekday=3)), ('W-FRI', Week(weekday=4))]

    for name, expected in pairs:
        offset = get_offset(name)
        assert offset == expected, ("Expected %r to yield %r (actual: %r)" %
                                    (name, expected, offset)) 
Example #11
Source File: test_frequencies.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_legacy_offset_warnings(self):
        freqs = ['WEEKDAY', 'EOM', 'W@MON', 'W@TUE', 'W@WED', 'W@THU',
                 'W@FRI', 'W@SAT', 'W@SUN', 'Q@JAN', 'Q@FEB', 'Q@MAR',
                 'A@JAN', 'A@FEB', 'A@MAR', 'A@APR', 'A@MAY', 'A@JUN',
                 'A@JUL', 'A@AUG', 'A@SEP', 'A@OCT', 'A@NOV', 'A@DEC',
                 'Y@JAN', 'WOM@1MON', 'WOM@2MON', 'WOM@3MON',
                 'WOM@4MON', 'WOM@1TUE', 'WOM@2TUE', 'WOM@3TUE',
                 'WOM@4TUE', 'WOM@1WED', 'WOM@2WED', 'WOM@3WED',
                 'WOM@4WED', 'WOM@1THU', 'WOM@2THU', 'WOM@3THU',
                 'WOM@4THU', 'WOM@1FRI', 'WOM@2FRI', 'WOM@3FRI',
                 'WOM@4FRI']

        msg = INVALID_FREQ_ERR_MSG
        for freq in freqs:
            with pytest.raises(ValueError, match=msg):
                frequencies.get_offset(freq)

            with pytest.raises(ValueError, match=msg):
                date_range('2011-01-01', periods=5, freq=freq) 
Example #12
Source File: test_frequencies.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_ms_vs_MS():
    left = frequencies.get_offset('ms')
    right = frequencies.get_offset('MS')
    assert left == offsets.Milli()
    assert right == offsets.MonthBegin() 
Example #13
Source File: test_offsets.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_offset_freqstr(self, offset_types):
        offset = self._get_offset(offset_types)

        freqstr = offset.freqstr
        if freqstr not in ('<Easter>',
                           "<DateOffset: days=1>",
                           'LWOM-SAT', ):
            code = get_offset(freqstr)
            assert offset.rule_code == code 
Example #14
Source File: test_frequencies.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_ms_vs_MS():
    left = frequencies.get_offset('ms')
    right = frequencies.get_offset('MS')
    assert left == offsets.Milli()
    assert right == offsets.MonthBegin() 
Example #15
Source File: test_offsets.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_str_for_named_is_name(self):
        # look at all the amazing combinations!
        month_prefixes = ['A', 'AS', 'BA', 'BAS', 'Q', 'BQ', 'BQS', 'QS']
        names = [prefix + '-' + month
                 for prefix in month_prefixes
                 for month in ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
                               'AUG', 'SEP', 'OCT', 'NOV', 'DEC']]
        days = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        names += ['W-' + day for day in days]
        names += ['WOM-' + week + day
                  for week in ('1', '2', '3', '4') for day in days]
        _offset_map.clear()
        for name in names:
            offset = get_offset(name)
            assert offset.freqstr == name 
Example #16
Source File: test_offsets.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_rule_code(self):
        lst = ['M', 'MS', 'BM', 'BMS', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
        for k in lst:
            assert k == get_offset(k).rule_code
            # should be cached - this is kind of an internals test...
            assert k in _offset_map
            assert k == (get_offset(k) * 3).rule_code

        suffix_lst = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        base = 'W'
        for v in suffix_lst:
            alias = '-'.join([base, v])
            assert alias == get_offset(alias).rule_code
            assert alias == (get_offset(alias) * 5).rule_code

        suffix_lst = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG',
                      'SEP', 'OCT', 'NOV', 'DEC']
        base_lst = ['A', 'AS', 'BA', 'BAS', 'Q', 'QS', 'BQ', 'BQS']
        for base in base_lst:
            for v in suffix_lst:
                alias = '-'.join([base, v])
                assert alias == get_offset(alias).rule_code
                assert alias == (get_offset(alias) * 5).rule_code

        lst = ['M', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
        for k in lst:
            code, stride = get_freq_code('3' + k)
            assert isinstance(code, int)
            assert stride == 3
            assert k == get_freq_str(code) 
Example #17
Source File: test_offsets.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_get_offset_legacy():
    pairs = [('w@Sat', Week(weekday=5))]
    for name, expected in pairs:
        with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
            get_offset(name) 
Example #18
Source File: test_offsets.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_get_offset_legacy():
    pairs = [('w@Sat', Week(weekday=5))]
    for name, expected in pairs:
        with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
            get_offset(name) 
Example #19
Source File: test_offsets.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_offset_freqstr(self, offset_types):
        offset = self._get_offset(offset_types)

        freqstr = offset.freqstr
        if freqstr not in ('<Easter>',
                           "<DateOffset: days=1>",
                           'LWOM-SAT', ):
            code = get_offset(freqstr)
            assert offset.rule_code == code 
Example #20
Source File: test_offsets.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_rule_code(self):
        lst = ['M', 'MS', 'BM', 'BMS', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
        for k in lst:
            assert k == get_offset(k).rule_code
            # should be cached - this is kind of an internals test...
            assert k in _offset_map
            assert k == (get_offset(k) * 3).rule_code

        suffix_lst = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        base = 'W'
        for v in suffix_lst:
            alias = '-'.join([base, v])
            assert alias == get_offset(alias).rule_code
            assert alias == (get_offset(alias) * 5).rule_code

        suffix_lst = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG',
                      'SEP', 'OCT', 'NOV', 'DEC']
        base_lst = ['A', 'AS', 'BA', 'BAS', 'Q', 'QS', 'BQ', 'BQS']
        for base in base_lst:
            for v in suffix_lst:
                alias = '-'.join([base, v])
                assert alias == get_offset(alias).rule_code
                assert alias == (get_offset(alias) * 5).rule_code

        lst = ['M', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
        for k in lst:
            code, stride = get_freq_code('3' + k)
            assert isinstance(code, int)
            assert stride == 3
            assert k == get_freq_str(code) 
Example #21
Source File: test_frequencies.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_ms_vs_MS():
    left = frequencies.get_offset('ms')
    right = frequencies.get_offset('MS')
    assert left == offsets.Milli()
    assert right == offsets.MonthBegin() 
Example #22
Source File: test_offsets.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_str_for_named_is_name(self):
        # look at all the amazing combinations!
        month_prefixes = ['A', 'AS', 'BA', 'BAS', 'Q', 'BQ', 'BQS', 'QS']
        names = [prefix + '-' + month
                 for prefix in month_prefixes
                 for month in ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
                               'AUG', 'SEP', 'OCT', 'NOV', 'DEC']]
        days = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        names += ['W-' + day for day in days]
        names += ['WOM-' + week + day
                  for week in ('1', '2', '3', '4') for day in days]
        _offset_map.clear()
        for name in names:
            offset = get_offset(name)
            assert offset.freqstr == name 
Example #23
Source File: test_offsets.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_rule_code(self):
        lst = ['M', 'MS', 'BM', 'BMS', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
        for k in lst:
            assert k == get_offset(k).rule_code
            # should be cached - this is kind of an internals test...
            assert k in _offset_map
            assert k == (get_offset(k) * 3).rule_code

        suffix_lst = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        base = 'W'
        for v in suffix_lst:
            alias = '-'.join([base, v])
            assert alias == get_offset(alias).rule_code
            assert alias == (get_offset(alias) * 5).rule_code

        suffix_lst = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG',
                      'SEP', 'OCT', 'NOV', 'DEC']
        base_lst = ['A', 'AS', 'BA', 'BAS', 'Q', 'QS', 'BQ', 'BQS']
        for base in base_lst:
            for v in suffix_lst:
                alias = '-'.join([base, v])
                assert alias == get_offset(alias).rule_code
                assert alias == (get_offset(alias) * 5).rule_code

        lst = ['M', 'D', 'B', 'H', 'T', 'S', 'L', 'U']
        for k in lst:
            code, stride = get_freq_code('3' + k)
            assert isinstance(code, int)
            assert stride == 3
            assert k == get_freq_str(code) 
Example #24
Source File: test_offsets.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_get_offset_legacy():
    pairs = [('w@Sat', Week(weekday=5))]
    for name, expected in pairs:
        with pytest.raises(ValueError, match=INVALID_FREQ_ERR_MSG):
            get_offset(name) 
Example #25
Source File: test_offsets.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_str_for_named_is_name(self):
        # look at all the amazing combinations!
        month_prefixes = ['A', 'AS', 'BA', 'BAS', 'Q', 'BQ', 'BQS', 'QS']
        names = [prefix + '-' + month
                 for prefix in month_prefixes
                 for month in ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
                               'AUG', 'SEP', 'OCT', 'NOV', 'DEC']]
        days = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        names += ['W-' + day for day in days]
        names += ['WOM-' + week + day
                  for week in ('1', '2', '3', '4') for day in days]
        _offset_map.clear()
        for name in names:
            offset = get_offset(name)
            assert offset.freqstr == name 
Example #26
Source File: test_offsets.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_offset_freqstr(self, offset_types):
        offset = self._get_offset(offset_types)

        freqstr = offset.freqstr
        if freqstr not in ('<Easter>',
                           "<DateOffset: days=1>",
                           'LWOM-SAT', ):
            code = get_offset(freqstr)
            assert offset.rule_code == code 
Example #27
Source File: test_offsets.py    From vnpy_crypto with MIT License 5 votes vote down vote up
def test_get_offset_legacy():
    pairs = [('w@Sat', Week(weekday=5))]
    for name, expected in pairs:
        with tm.assert_raises_regex(ValueError, _INVALID_FREQ_ERROR):
            get_offset(name) 
Example #28
Source File: test_frequencies.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_ms_vs_MS():
    left = frequencies.get_offset('ms')
    right = frequencies.get_offset('MS')
    assert left == offsets.Milli()
    assert right == offsets.MonthBegin() 
Example #29
Source File: test_frequencies.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_ms_vs_MS():
    left = frequencies.get_offset('ms')
    right = frequencies.get_offset('MS')
    assert left == offsets.Milli()
    assert right == offsets.MonthBegin() 
Example #30
Source File: test_offsets.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_str_for_named_is_name(self):
        # look at all the amazing combinations!
        month_prefixes = ['A', 'AS', 'BA', 'BAS', 'Q', 'BQ', 'BQS', 'QS']
        names = [prefix + '-' + month
                 for prefix in month_prefixes
                 for month in ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL',
                               'AUG', 'SEP', 'OCT', 'NOV', 'DEC']]
        days = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        names += ['W-' + day for day in days]
        names += ['WOM-' + week + day
                  for week in ('1', '2', '3', '4') for day in days]
        _offset_map.clear()
        for name in names:
            offset = get_offset(name)
            assert offset.freqstr == name