({ "microseconds": 0 }, offsets.Nano(0)), ], ) def test_to_offset_pd_timedelta(kwargs, expected): # see gh-9064 td = Timedelta(**kwargs) result = to_offset(td) assert result == expected @pytest.mark.parametrize( "shortcut,expected", [ ("W", offsets.Week(weekday=6)), ("W-SUN", offsets.Week(weekday=6)), ("Q", offsets.QuarterEnd(startingMonth=12)), ("Q-DEC", offsets.QuarterEnd(startingMonth=12)), ("Q-MAY", offsets.QuarterEnd(startingMonth=5)), ("SM", offsets.SemiMonthEnd(day_of_month=15)), ("SM-15", offsets.SemiMonthEnd(day_of_month=15)), ("SM-1", offsets.SemiMonthEnd(day_of_month=1)), ("SM-27", offsets.SemiMonthEnd(day_of_month=27)), ("SMS-2", offsets.SemiMonthBegin(day_of_month=2)), ("SMS-27", offsets.SemiMonthBegin(day_of_month=27)), ], ) def test_anchored_shortcuts(shortcut, expected): result = to_offset(shortcut) assert result == expected
("3A", 1000), ("-1A", 1000), ("A-JAN", 1000), ("A-MAY", 1000), ("Y", 1000), ("3Y", 1000), ("-1Y", 1000), ("Y-JAN", 1000), ("Y-MAY", 1000), (offsets.YearEnd(), 1000), (offsets.YearEnd(month=1), 1000), (offsets.YearEnd(month=5), 1000), ("W", 4000), ("W-MON", 4000), ("W-FRI", 4000), (offsets.Week(), 4000), (offsets.Week(weekday=1), 4000), (offsets.Week(weekday=5), 4000), ("T", FreqGroup.FR_MIN), ], ) def test_freq_group(freqstr, expected): assert get_freq_group(freqstr) == expected def test_freq_group_match(period_code_item): freqstr, code = period_code_item str_group = get_freq_group(freqstr) code_group = get_freq_group(code)