Skip to content

Commit 2abd0ed

Browse files
Update parse_iso_format_string and tests that give warnings
1 parent 3682687 commit 2abd0ed

File tree

9 files changed

+24
-24
lines changed

9 files changed

+24
-24
lines changed

doc/source/whatsnew/v0.15.0.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Access fields for a ``Timedelta``
163163

164164
.. ipython:: python
165165
166-
td = pd.Timedelta('1 hour 3m 15.5us')
166+
td = pd.Timedelta('1 hour 3min 15.5us')
167167
td.seconds
168168
td.microseconds
169169
td.nanoseconds
@@ -1030,12 +1030,11 @@ Other:
10301030
If ``Period`` freq is ``D``, ``H``, ``T``, ``S``, ``L``, ``U``, ``N``, ``Timedelta``-like can be added if the result can have same freq. Otherwise, only the same ``offsets`` can be added.
10311031

10321032
.. ipython:: python
1033-
:okwarning:
10341033
10351034
idx = pd.period_range('2014-07-01 09:00', periods=5, freq='H')
10361035
idx
10371036
idx + pd.offsets.Hour(2)
1038-
idx + pd.Timedelta('120m')
1037+
idx + pd.Timedelta('120min')
10391038
10401039
idx = pd.period_range('2014-07', periods=5, freq='M')
10411040
idx

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,11 @@ cdef inline int64_t parse_iso_format_string(str ts) except? -1:
645645
else:
646646
neg = 1
647647
elif c in ['W', 'D', 'H', 'M']:
648-
unit.append(c)
649648
if c in ['H', 'M'] and len(number) > 2:
650649
raise ValueError(err_msg)
650+
if c == 'M':
651+
c = 'min'
652+
unit.append(c)
651653
r = timedelta_from_spec(number, '0', unit)
652654
result += timedelta_as_neg(r, neg)
653655

pandas/tests/arithmetic/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ def numeric_idx(request):
113113

114114
@pytest.fixture(
115115
params=[
116-
pd.Timedelta("5m4s").to_pytimedelta(),
117-
pd.Timedelta("5m4s"),
118-
pd.Timedelta("5m4s").to_timedelta64(),
116+
pd.Timedelta("5min4s").to_pytimedelta(),
117+
pd.Timedelta("5min4s"),
118+
pd.Timedelta("5min4s").to_timedelta64(),
119119
],
120120
ids=lambda x: type(x).__name__,
121121
)

pandas/tests/arithmetic/test_timedelta64.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,8 +1860,8 @@ def test_td64arr_floordiv_tdlike_scalar(self, two_hours, box_with_array):
18601860
"scalar_td",
18611861
[
18621862
timedelta(minutes=10, seconds=7),
1863-
Timedelta("10m7s"),
1864-
Timedelta("10m7s").to_timedelta64(),
1863+
Timedelta("10min7s"),
1864+
Timedelta("10min7s").to_timedelta64(),
18651865
],
18661866
ids=lambda x: type(x).__name__,
18671867
)
@@ -2060,7 +2060,7 @@ def test_td64arr_div_numeric_array(self, box_with_array, vector, any_real_dtype)
20602060
tdser = Series(["59 Days", "59 Days", "NaT"], dtype="m8[ns]")
20612061
vector = vector.astype(any_real_dtype)
20622062

2063-
expected = Series(["2.95D", "1D 23H 12m", "NaT"], dtype="timedelta64[ns]")
2063+
expected = Series(["2.95D", "1D 23H 12min", "NaT"], dtype="timedelta64[ns]")
20642064

20652065
tdser = tm.box_expected(tdser, box_with_array)
20662066
expected = tm.box_expected(expected, xbox)

pandas/tests/arrays/test_timedeltas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def test_std(self):
271271
assert result is pd.NaT
272272

273273
def test_median(self):
274-
tdi = pd.TimedeltaIndex(["0H", "3H", "NaT", "5H06m", "0H", "2H"])
274+
tdi = pd.TimedeltaIndex(["0H", "3H", "NaT", "5H06min", "0H", "2H"])
275275
arr = tdi.array
276276

277277
result = arr.median(skipna=True)

pandas/tests/resample/test_datetime_index.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ def test_resample_origin():
759759
resampled = ts.resample("5min", origin="1999-12-31 12:02:00").mean()
760760
tm.assert_index_equal(resampled.index, exp_rng)
761761

762-
resampled = ts.resample("5min", offset="-3m").mean()
762+
resampled = ts.resample("5min", offset="-3min").mean()
763763
tm.assert_index_equal(resampled.index, exp_rng)
764764

765765

@@ -831,8 +831,7 @@ def test_resample_origin_with_tz():
831831
resampled = ts.resample("5min", origin="1999-12-31 12:02:00+03:00").mean()
832832
tm.assert_index_equal(resampled.index, exp_rng)
833833

834-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
835-
resampled = ts.resample("5min", origin="epoch", offset="2m").mean()
834+
resampled = ts.resample("5min", origin="epoch", offset="2min").mean()
836835
tm.assert_index_equal(resampled.index, exp_rng)
837836

838837
with pytest.raises(ValueError, match=msg):

pandas/tests/scalar/interval/test_interval.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def test_hash(self, interval):
7979
(-np.inf, np.inf, np.inf),
8080
(Timedelta("0 days"), Timedelta("5 days"), Timedelta("5 days")),
8181
(Timedelta("10 days"), Timedelta("10 days"), Timedelta("0 days")),
82-
(Timedelta("1H10M"), Timedelta("5H5M"), Timedelta("3H55M")),
83-
(Timedelta("5S"), Timedelta("1H"), Timedelta("59M55S")),
82+
(Timedelta("1H10min"), Timedelta("5H5min"), Timedelta("3H55min")),
83+
(Timedelta("5S"), Timedelta("1H"), Timedelta("59min55S")),
8484
],
8585
)
8686
def test_length(self, left, right, expected):

pandas/tests/scalar/timedelta/test_constructors.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,31 @@ def test_construction():
6262
# combos
6363
assert Timedelta("10 days 1 hour") == timedelta(days=10, hours=1)
6464
assert Timedelta("10 days 1 h") == timedelta(days=10, hours=1)
65-
assert Timedelta("10 days 1 h 1m 1s") == timedelta(
65+
assert Timedelta("10 days 1 h 1min 1s") == timedelta(
6666
days=10, hours=1, minutes=1, seconds=1
6767
)
68-
assert Timedelta("-10 days 1 h 1m 1s") == -timedelta(
68+
assert Timedelta("-10 days 1 h 1min 1s") == -timedelta(
6969
days=10, hours=1, minutes=1, seconds=1
7070
)
71-
assert Timedelta("-10 days 1 h 1m 1s") == -timedelta(
71+
assert Timedelta("-10 days 1 h 1min 1s") == -timedelta(
7272
days=10, hours=1, minutes=1, seconds=1
7373
)
74-
assert Timedelta("-10 days 1 h 1m 1s 3us") == -timedelta(
74+
assert Timedelta("-10 days 1 h 1min 1s 3us") == -timedelta(
7575
days=10, hours=1, minutes=1, seconds=1, microseconds=3
7676
)
77-
assert Timedelta("-10 days 1 h 1.5m 1s 3us") == -timedelta(
77+
assert Timedelta("-10 days 1 h 1.5min 1s 3us") == -timedelta(
7878
days=10, hours=1, minutes=1, seconds=31, microseconds=3
7979
)
8080

8181
# Currently invalid as it has a - on the hh:mm:dd part
8282
# (only allowed on the days)
8383
msg = "only leading negative signs are allowed"
8484
with pytest.raises(ValueError, match=msg):
85-
Timedelta("-10 days -1 h 1.5m 1s 3us")
85+
Timedelta("-10 days -1 h 1.5min 1s 3us")
8686

8787
# only leading neg signs are allowed
8888
with pytest.raises(ValueError, match=msg):
89-
Timedelta("10 days -1 h 1.5m 1s 3us")
89+
Timedelta("10 days -1 h 1.5min 1s 3us")
9090

9191
# no units specified
9292
msg = "no units specified"

pandas/tests/scalar/timedelta/test_timedelta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ def test_timedelta_conversions(self):
309309

310310
def test_to_numpy_alias(self):
311311
# GH 24653: alias .to_numpy() for scalars
312-
td = Timedelta("10m7s")
312+
td = Timedelta("10min7s")
313313
assert td.to_timedelta64() == td.to_numpy()
314314

315315
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)