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


Python frequencies.get_offset方法代码示例

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


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

示例1: test_get_offset

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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)) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_offsets.py

示例2: test_legacy_offset_warnings

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:test_frequencies.py

示例3: test_get_offset

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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)) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:18,代码来源:test_offsets.py

示例4: test_legacy_offset_warnings

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:21,代码来源:test_frequencies.py

示例5: test_legacy_offset_warnings

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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) 
开发者ID:securityclippy,项目名称:elasticintel,代码行数:21,代码来源:test_frequencies.py

示例6: test_offset_freqstr

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:test_offsets.py

示例7: test_get_offset_legacy

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_offsets.py

示例8: test_rule_code

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:32,代码来源:test_offsets.py

示例9: test_str_for_named_is_name

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:17,代码来源:test_offsets.py

示例10: test_ms_vs_MS

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
def test_ms_vs_MS():
    left = frequencies.get_offset('ms')
    right = frequencies.get_offset('MS')
    assert left == offsets.Milli()
    assert right == offsets.MonthBegin() 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:7,代码来源:test_frequencies.py

示例11: test_get_offset_legacy

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
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) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:7,代码来源:test_offsets.py

示例12: _make_offset

# 需要导入模块: from pandas.tseries import frequencies [as 别名]
# 或者: from pandas.tseries.frequencies import get_offset [as 别名]
def _make_offset(key):
    """Gets offset based on key. KeyError if prefix is bad, ValueError if
    suffix is bad. All handled by `get_offset` in tseries/frequencies. Not
    public."""
    if key is None:
        return None
    split = key.replace('@', '-').split('-')
    klass = prefix_mapping[split[0]]
    # handles case where there's no suffix (and will TypeError if too many '-')
    obj = klass._from_name(*split[1:])
    obj._named = key
    return obj 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:offsets.py


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