Skip to content

Commit ad28eff

Browse files
committed
Small fixes
1 parent eb9b703 commit ad28eff

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pandas/core/tools/timedeltas.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
timedelta support tools
33
"""
44

5-
import numpy as np
65
import warnings
6+
import numpy as np
7+
78

89
from pandas._libs import tslibs
910
from pandas._libs.tslibs.timedeltas import (
@@ -93,7 +94,7 @@ def to_timedelta(arg, unit='ns', box=True, errors='raise'):
9394
raise ValueError("errors must be one of 'ignore', "
9495
"'raise', or 'coerce'}")
9596

96-
if unit in ['Y', 'y', 'M']:
97+
if unit in {'Y', 'y', 'M'}:
9798
warnings.warn("M and Y units are deprecated.",
9899
FutureWarning, stacklevel=2)
99100

pandas/tests/scalar/timedelta/test_timedelta.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,10 @@ def test_unit_parser(self, units, np_unit, wrapper):
356356

357357
@pytest.mark.parametrize('units', ['Y', 'y', 'M'])
358358
def test_unit_M_Y_deprecated(self, units):
359-
for unit in units:
360-
with tm.assert_produces_warning(FutureWarning):
361-
to_timedelta(10, unit)
362-
TimedeltaIndex([1, 1, 1], unit)
363-
Timedelta(10, unit)
359+
with tm.assert_produces_warning(FutureWarning):
360+
to_timedelta(10, units)
361+
TimedeltaIndex([1, 1, 1], units)
362+
Timedelta(10, units)
364363

365364
def test_numeric_conversions(self):
366365
assert ct(0) == np.timedelta64(0, 'ns')

0 commit comments

Comments
 (0)