Skip to content

Commit d8e8ad9

Browse files
committed
Add 'W' as a valid ISO 8601 designator
1 parent 9292728 commit d8e8ad9

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

pandas/_libs/tslibs/timedeltas.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ cdef inline int64_t parse_iso_format_string(str ts) except? -1:
620620
if not len(unit):
621621
number.append(c)
622622
else:
623-
if 'H' in unit or 'M' in unit:
623+
if 'H' in unit or 'M' in unit or 'W' in unit:
624624
if len(number) > 2:
625625
raise ValueError(err_msg)
626626
r = timedelta_from_spec(number, '0', unit)
@@ -636,7 +636,7 @@ cdef inline int64_t parse_iso_format_string(str ts) except? -1:
636636
raise ValueError(err_msg)
637637
else:
638638
neg = 1
639-
elif c in ['D', 'H', 'M']:
639+
elif c in ['W', 'D', 'H', 'M']:
640640
unit.append(c)
641641
elif c == '.':
642642
# append any seconds

pandas/tests/scalar/timedelta/test_constructors.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ def test_overflow_on_construction():
230230
("P1DT25H61M61S", Timedelta(days=1, hours=25, minutes=61, seconds=61)),
231231
("PT1S", Timedelta(seconds=1)),
232232
("PT0S", Timedelta(seconds=0)),
233+
("P1WT0S", Timedelta(days=7, seconds=0)),
233234
],
234235
)
235236
def test_iso_constructor(fmt, exp):

0 commit comments

Comments
 (0)