本文整理汇总了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
示例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
示例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')
示例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')
示例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))
示例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))
示例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)