|
7 | 7 | TYPE_CHECKING,
|
8 | 8 | overload,
|
9 | 9 | )
|
| 10 | +import warnings |
10 | 11 |
|
11 | 12 | import numpy as np
|
12 | 13 |
|
|
19 | 20 | Timedelta,
|
20 | 21 | parse_timedelta_unit,
|
21 | 22 | )
|
| 23 | +from pandas.util._exceptions import find_stack_level |
22 | 24 |
|
23 | 25 | from pandas.core.dtypes.common import is_list_like
|
24 | 26 | from pandas.core.dtypes.generic import (
|
@@ -110,14 +112,17 @@ def to_timedelta(
|
110 | 112 | * 'W'
|
111 | 113 | * 'D' / 'days' / 'day'
|
112 | 114 | * 'hours' / 'hour' / 'hr' / 'h'
|
113 |
| - * 'm' / 'minute' / 'min' / 'minutes' |
| 115 | + * 'm' / 'minute' / 'min' / 'minutes' / 'T' |
114 | 116 | * 'S' / 'seconds' / 'sec' / 'second'
|
115 |
| - * 'ms' / 'milliseconds' / 'millisecond' / 'milli' / 'millis' |
| 117 | + * 'ms' / 'milliseconds' / 'millisecond' / 'milli' / 'millis' / 'L' |
116 | 118 | * 'us' / 'microseconds' / 'microsecond' / 'micro' / 'micros' / 'U'
|
117 | 119 | * 'ns' / 'nanoseconds' / 'nano' / 'nanos' / 'nanosecond' / 'N'
|
118 | 120 |
|
119 | 121 | Must not be specified when `arg` context strings and ``errors="raise"``.
|
120 | 122 |
|
| 123 | + .. deprecated:: 2.1.0 |
| 124 | + Units 'T' and 'L' are deprecated and will be removed in a future version. |
| 125 | +
|
121 | 126 | errors : {'ignore', 'raise', 'coerce'}, default 'raise'
|
122 | 127 | - If 'raise', then invalid parsing will raise an exception.
|
123 | 128 | - If 'coerce', then invalid parsing will be set as NaT.
|
@@ -181,8 +186,12 @@ def to_timedelta(
|
181 | 186 | "represent unambiguous timedelta values durations."
|
182 | 187 | )
|
183 | 188 |
|
184 |
| - if unit in {"t", "T", "l", "L"}: |
185 |
| - raise ValueError("Units 't', 'T', 'l' and 'L' are no longer supported.") |
| 189 | + if unit in {"T", "t", "L", "l"}: |
| 190 | + warnings.warn( |
| 191 | + f"Unit {unit} is deprecated and will be removed in a future version.", |
| 192 | + FutureWarning, |
| 193 | + stacklevel=find_stack_level(), |
| 194 | + ) |
186 | 195 |
|
187 | 196 | if arg is None:
|
188 | 197 | return arg
|
|
0 commit comments