當前位置: 首頁>>代碼示例>>Python>>正文


Python offsets.Week方法代碼示例

本文整理匯總了Python中pandas.tseries.offsets.Week方法的典型用法代碼示例。如果您正苦於以下問題:Python offsets.Week方法的具體用法?Python offsets.Week怎麽用?Python offsets.Week使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pandas.tseries.offsets的用法示例。


在下文中一共展示了offsets.Week方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_freq_group

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
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 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:25,代碼來源:test_frequencies.py

示例2: test_freq_group

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
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 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:25,代碼來源:test_frequencies.py

示例3: test_get_rule_month

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
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') 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:35,代碼來源:test_libfrequencies.py

示例4: test_get_rule_month

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
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') 
開發者ID:securityclippy,項目名稱:elasticintel,代碼行數:36,代碼來源:test_frequencies.py

示例5: test_get_freq_code

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
def test_get_freq_code(self):
        # frequency str
        assert (get_freq_code('A') ==
                (get_freq('A'), 1))
        assert (get_freq_code('3D') ==
                (get_freq('D'), 3))
        assert (get_freq_code('-2M') ==
                (get_freq('M'), -2))

        # tuple
        assert (get_freq_code(('D', 1)) ==
                (get_freq('D'), 1))
        assert (get_freq_code(('A', 3)) ==
                (get_freq('A'), 3))
        assert (get_freq_code(('M', -2)) ==
                (get_freq('M'), -2))

        # numeric tuple
        assert get_freq_code((1000, 1)) == (1000, 1)

        # offsets
        assert (get_freq_code(offsets.Day()) ==
                (get_freq('D'), 1))
        assert (get_freq_code(offsets.Day(3)) ==
                (get_freq('D'), 3))
        assert (get_freq_code(offsets.Day(-2)) ==
                (get_freq('D'), -2))

        assert (get_freq_code(offsets.MonthEnd()) ==
                (get_freq('M'), 1))
        assert (get_freq_code(offsets.MonthEnd(3)) ==
                (get_freq('M'), 3))
        assert (get_freq_code(offsets.MonthEnd(-2)) ==
                (get_freq('M'), -2))

        assert (get_freq_code(offsets.Week()) ==
                (get_freq('W'), 1))
        assert (get_freq_code(offsets.Week(3)) ==
                (get_freq('W'), 3))
        assert (get_freq_code(offsets.Week(-2)) ==
                (get_freq('W'), -2))

        # Monday is weekday=0
        assert (get_freq_code(offsets.Week(weekday=1)) ==
                (get_freq('W-TUE'), 1))
        assert (get_freq_code(offsets.Week(3, weekday=0)) ==
                (get_freq('W-MON'), 3))
        assert (get_freq_code(offsets.Week(-2, weekday=4)) ==
                (get_freq('W-FRI'), -2)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:51,代碼來源:test_frequencies.py

示例6: test_get_freq_code

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
def test_get_freq_code(self):
        # frequency str
        assert (frequencies.get_freq_code('A') ==
                (frequencies.get_freq('A'), 1))
        assert (frequencies.get_freq_code('3D') ==
                (frequencies.get_freq('D'), 3))
        assert (frequencies.get_freq_code('-2M') ==
                (frequencies.get_freq('M'), -2))

        # tuple
        assert (frequencies.get_freq_code(('D', 1)) ==
                (frequencies.get_freq('D'), 1))
        assert (frequencies.get_freq_code(('A', 3)) ==
                (frequencies.get_freq('A'), 3))
        assert (frequencies.get_freq_code(('M', -2)) ==
                (frequencies.get_freq('M'), -2))

        # numeric tuple
        assert frequencies.get_freq_code((1000, 1)) == (1000, 1)

        # offsets
        assert (frequencies.get_freq_code(offsets.Day()) ==
                (frequencies.get_freq('D'), 1))
        assert (frequencies.get_freq_code(offsets.Day(3)) ==
                (frequencies.get_freq('D'), 3))
        assert (frequencies.get_freq_code(offsets.Day(-2)) ==
                (frequencies.get_freq('D'), -2))

        assert (frequencies.get_freq_code(offsets.MonthEnd()) ==
                (frequencies.get_freq('M'), 1))
        assert (frequencies.get_freq_code(offsets.MonthEnd(3)) ==
                (frequencies.get_freq('M'), 3))
        assert (frequencies.get_freq_code(offsets.MonthEnd(-2)) ==
                (frequencies.get_freq('M'), -2))

        assert (frequencies.get_freq_code(offsets.Week()) ==
                (frequencies.get_freq('W'), 1))
        assert (frequencies.get_freq_code(offsets.Week(3)) ==
                (frequencies.get_freq('W'), 3))
        assert (frequencies.get_freq_code(offsets.Week(-2)) ==
                (frequencies.get_freq('W'), -2))

        # Monday is weekday=0
        assert (frequencies.get_freq_code(offsets.Week(weekday=1)) ==
                (frequencies.get_freq('W-TUE'), 1))
        assert (frequencies.get_freq_code(offsets.Week(3, weekday=0)) ==
                (frequencies.get_freq('W-MON'), 3))
        assert (frequencies.get_freq_code(offsets.Week(-2, weekday=4)) ==
                (frequencies.get_freq('W-FRI'), -2)) 
開發者ID:birforce,項目名稱:vnpy_crypto,代碼行數:51,代碼來源:test_frequencies.py

示例7: time_features_from_frequency_str

# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import Week [as 別名]
def time_features_from_frequency_str(freq_str: str) -> List[TimeFeature]:
    """
    Returns a list of time features that will be appropriate for the given frequency string.

    Parameters
    ----------

    freq_str
        Frequency string of the form [multiple][granularity] such as "12H", "5min", "1D" etc.

    """

    features_by_offsets = {
        offsets.YearOffset: [],
        offsets.MonthOffset: [MonthOfYear],
        offsets.Week: [DayOfMonth, WeekOfYear],
        offsets.Day: [DayOfWeek, DayOfMonth, DayOfYear],
        offsets.BusinessDay: [DayOfWeek, DayOfMonth, DayOfYear],
        offsets.Hour: [HourOfDay, DayOfWeek, DayOfMonth, DayOfYear],
        offsets.Minute: [
            MinuteOfHour,
            HourOfDay,
            DayOfWeek,
            DayOfMonth,
            DayOfYear,
        ],
    }

    offset = to_offset(freq_str)

    for offset_type, feature_classes in features_by_offsets.items():
        if isinstance(offset, offset_type):
            return [cls() for cls in feature_classes]

    supported_freq_msg = f"""
    Unsupported frequency {freq_str}

    The following frequencies are supported:

        Y   - yearly
            alias: A
        M   - monthly
        W   - weekly
        D   - daily
        B   - business days
        H   - hourly
        T   - minutely
            alias: min
    """
    raise RuntimeError(supported_freq_msg) 
開發者ID:awslabs,項目名稱:gluon-ts,代碼行數:52,代碼來源:_base.py


注:本文中的pandas.tseries.offsets.Week方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。