Skip to content

DEPR: DateOffset args don't end in 's' #36660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ Deprecations
- Deprecated indexing :class:`DataFrame` rows with datetime-like strings ``df[string]``, use ``df.loc[string]`` instead (:issue:`36179`)
- Deprecated casting an object-dtype index of ``datetime`` objects to :class:`DatetimeIndex` in the :class:`Series` constructor (:issue:`23598`)
- Deprecated :meth:`Index.is_all_dates` (:issue:`27744`)
- Use of Date Offset arguments that do not end with 's' overwrites the offset instead of incrementing it. These arguments are deprecated now and slated for removal in a future version (:issue:`36660`)

.. ---------------------------------------------------------------------------

Expand Down
11 changes: 11 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ cdef _determine_offset(kwds):
'year', 'month', 'week', 'day', 'weekday',
'hour', 'minute', 'second', 'microsecond')

if any(not k.endswith('s') for k in kwds_no_nanos):
if 'weekday' not in kwds_no_nanos:
warnings.warn(
"Date Offset arguments that do not end with 's' overwrites "
"the offset instead of incrementing it. These arguments "
"are deprecated now and slated for removal in a future "
"version.",
FutureWarning,
stacklevel=1,
)

use_relativedelta = False
if len(kwds_no_nanos) > 0:
if any(k in _kwds_use_relativedelta for k in kwds_no_nanos):
Expand Down