Skip to content

Commit 4963cb1

Browse files
committed
Adding depracated warning for units M and Y
1 parent a784aee commit 4963cb1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pandas/core/tools/timedeltas.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
is_timedelta64_dtype,
1515
is_list_like)
1616
from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass
17+
import warnings
1718

1819

1920
def to_timedelta(arg, unit='ns', box=True, errors='raise'):
@@ -130,6 +131,9 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
130131
def _validate_timedelta_unit(arg):
131132
""" provide validation / translation for timedelta short units """
132133
try:
134+
if arg == 'Y' or arg == 'y' or arg == 'M':
135+
warnings.warn("Month and year units are deprecated.",
136+
FutureWarning, stacklevel=2)
133137
return _unit_map[arg]
134138
except (KeyError, TypeError):
135139
if arg is None:

0 commit comments

Comments
 (0)