本文整理匯總了Python中pandas.tseries.offsets.QuarterEnd方法的典型用法代碼示例。如果您正苦於以下問題:Python offsets.QuarterEnd方法的具體用法?Python offsets.QuarterEnd怎麽用?Python offsets.QuarterEnd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pandas.tseries.offsets
的用法示例。
在下文中一共展示了offsets.QuarterEnd方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_get_rule_month
# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import QuarterEnd [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')
示例2: test_get_rule_month
# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import QuarterEnd [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')
示例3: test_anchored_shortcuts
# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import QuarterEnd [as 別名]
def test_anchored_shortcuts(self):
result = frequencies.to_offset('W')
expected = frequencies.to_offset('W-SUN')
assert (result == expected)
result1 = frequencies.to_offset('Q')
result2 = frequencies.to_offset('Q-DEC')
expected = offsets.QuarterEnd(startingMonth=12)
assert (result1 == expected)
assert (result2 == expected)
result1 = frequencies.to_offset('Q-MAY')
expected = offsets.QuarterEnd(startingMonth=5)
assert (result1 == expected)
result1 = frequencies.to_offset('SM')
result2 = frequencies.to_offset('SM-15')
expected = offsets.SemiMonthEnd(day_of_month=15)
assert (result1 == expected)
assert (result2 == expected)
result = frequencies.to_offset('SM-1')
expected = offsets.SemiMonthEnd(day_of_month=1)
assert (result == expected)
result = frequencies.to_offset('SM-27')
expected = offsets.SemiMonthEnd(day_of_month=27)
assert (result == expected)
result = frequencies.to_offset('SMS-2')
expected = offsets.SemiMonthBegin(day_of_month=2)
assert (result == expected)
result = frequencies.to_offset('SMS-27')
expected = offsets.SemiMonthBegin(day_of_month=27)
assert (result == expected)
# ensure invalid cases fail as expected
invalid_anchors = ['SM-0', 'SM-28', 'SM-29',
'SM-FOO', 'BSM', 'SM--1',
'SMS-1', 'SMS-28', 'SMS-30',
'SMS-BAR', 'SMS-BYR' 'BSMS',
'SMS--2']
for invalid_anchor in invalid_anchors:
with tm.assert_raises_regex(ValueError,
'Invalid frequency: '):
frequencies.to_offset(invalid_anchor)
示例4: test_anchored_shortcuts
# 需要導入模塊: from pandas.tseries import offsets [as 別名]
# 或者: from pandas.tseries.offsets import QuarterEnd [as 別名]
def test_anchored_shortcuts(self):
result = frequencies.to_offset('W')
expected = frequencies.to_offset('W-SUN')
assert (result == expected)
result1 = frequencies.to_offset('Q')
result2 = frequencies.to_offset('Q-DEC')
expected = offsets.QuarterEnd(startingMonth=12)
assert (result1 == expected)
assert (result2 == expected)
result1 = frequencies.to_offset('Q-MAY')
expected = offsets.QuarterEnd(startingMonth=5)
assert (result1 == expected)
result1 = frequencies.to_offset('SM')
result2 = frequencies.to_offset('SM-15')
expected = offsets.SemiMonthEnd(day_of_month=15)
assert (result1 == expected)
assert (result2 == expected)
result = frequencies.to_offset('SM-1')
expected = offsets.SemiMonthEnd(day_of_month=1)
assert (result == expected)
result = frequencies.to_offset('SM-27')
expected = offsets.SemiMonthEnd(day_of_month=27)
assert (result == expected)
result = frequencies.to_offset('SMS-2')
expected = offsets.SemiMonthBegin(day_of_month=2)
assert (result == expected)
result = frequencies.to_offset('SMS-27')
expected = offsets.SemiMonthBegin(day_of_month=27)
assert (result == expected)
# ensure invalid cases fail as expected
invalid_anchors = ['SM-0', 'SM-28', 'SM-29',
'SM-FOO', 'BSM', 'SM--1',
'SMS-1', 'SMS-28', 'SMS-30',
'SMS-BAR', 'SMS-BYR' 'BSMS',
'SMS--2']
for invalid_anchor in invalid_anchors:
with pytest.raises(ValueError, match='Invalid frequency: '):
frequencies.to_offset(invalid_anchor)