Skip to content

Commit e63c935

Browse files
jbrockmendeljreback
authored andcommitted
Lock down kwargs in offsets signatures (#17458)
1 parent 1335090 commit e63c935

File tree

5 files changed

+95
-65
lines changed

5 files changed

+95
-65
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ Other API Changes
703703
- :func:`to_datetime` when passed a tz-aware ``origin=`` kwarg will now raise a more informative ``ValueError`` rather than a ``TypeError`` (:issue:`16842`)
704704
- Renamed non-functional ``index`` to ``index_col`` in :func:`read_stata` to improve API consistency (:issue:`16342`)
705705
- Bug in :func:`DataFrame.drop` caused boolean labels ``False`` and ``True`` to be treated as labels 0 and 1 respectively when dropping indices from a numeric index. This will now raise a ValueError (:issue:`16877`)
706+
- Restricted DateOffset keyword arguments. Previously, ``DateOffset`` subclasses allowed arbitrary keyword arguments which could lead to unexpected behavior. Now, only valid arguments will be accepted. (:issue:`17176`).
706707
- Pandas no longer registers matplotlib converters on import. The converters
707708
will be registered and used when the first plot is draw (:issue:`17710`)
708709

Binary file not shown.
Binary file not shown.

pandas/tests/io/generate_legacy_storage_files.py

+16-2
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@
4545
from pandas.tseries.offsets import (
4646
DateOffset, Hour, Minute, Day,
4747
MonthBegin, MonthEnd, YearBegin,
48-
YearEnd, Week,
48+
YearEnd, Week, WeekOfMonth, LastWeekOfMonth,
49+
BusinessDay, BusinessHour, CustomBusinessDay, FY5253,
50+
Easter,
51+
SemiMonthEnd, SemiMonthBegin,
4952
QuarterBegin, QuarterEnd)
5053
from pandas.compat import u
5154
import os
5255
import sys
5356
import numpy as np
5457
import pandas
5558
import platform as pl
56-
59+
from datetime import timedelta
5760

5861
_loose_version = LooseVersion(pandas.__version__)
5962

@@ -201,6 +204,12 @@ def create_data():
201204
freq='M')
202205

203206
off = {'DateOffset': DateOffset(years=1),
207+
'DateOffset_h_ns': DateOffset(hour=6, nanoseconds=5824),
208+
'BusinessDay': BusinessDay(offset=timedelta(seconds=9)),
209+
'BusinessHour': BusinessHour(normalize=True, n=6, end='15:14'),
210+
'CustomBusinessDay': CustomBusinessDay(weekmask='Mon Fri'),
211+
'SemiMonthBegin': SemiMonthBegin(day_of_month=9),
212+
'SemiMonthEnd': SemiMonthEnd(day_of_month=24),
204213
'MonthBegin': MonthBegin(1),
205214
'MonthEnd': MonthEnd(1),
206215
'QuarterBegin': QuarterBegin(1),
@@ -209,6 +218,11 @@ def create_data():
209218
'YearBegin': YearBegin(1),
210219
'YearEnd': YearEnd(1),
211220
'Week': Week(1),
221+
'Week_Tues': Week(2, normalize=False, weekday=1),
222+
'WeekOfMonth': WeekOfMonth(week=3, weekday=4),
223+
'LastWeekOfMonth': LastWeekOfMonth(n=1, weekday=3),
224+
'FY5253': FY5253(n=2, weekday=6, startingMonth=7, variation="last"),
225+
'Easter': Easter(),
212226
'Hour': Hour(1),
213227
'Minute': Minute(1)}
214228

0 commit comments

Comments
 (0)