Skip to content

Commit e1a6106

Browse files
author
MomIsBestFriend
committed
Fix testcase
1 parent 56f03b4 commit e1a6106

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

pandas/_libs/tslibs/nattype.pyx

+7
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,14 @@ class NaTType(_NaT):
467467
Return a new Timestamp representing UTC day and time.
468468
"""
469469
)
470+
fromisocalendar = _make_error_func('fromisocalendar', # noqa:E128
471+
"""
472+
Timestamp.fromisocalendar(year, week, day)
470473
474+
Return a new Timestamp corresponding to the
475+
ISO calendar date specified by year, week and day.
476+
"""
477+
)
471478
timestamp = _make_error_func('timestamp', # noqa:E128
472479
"""Return POSIX timestamp as float.""")
473480

pandas/_libs/tslibs/timestamps.pyx

+7
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,13 @@ class Timestamp(_Timestamp):
344344
Return a new Timestamp corresponding to the
345345
ISO calendar date specified by year, week and day.
346346
"""
347+
import pandas.compact as compact
348+
349+
if not compact.PY38:
350+
raise NotImplementedError(
351+
"'fromisocalendar' is not supported for versions earlier to 3.8"
352+
)
353+
347354
return cls(datetime.fromisocalendar(year, week, day))
348355

349356
def __new__(cls, object ts_input=_no_input,

pandas/tests/scalar/test_nat.py

+1
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def test_overlap_public_nat_methods(klass, expected):
297297
# "fromisoformat" was introduced in 3.7
298298
if klass is Timestamp and not compat.PY37:
299299
expected.remove("fromisoformat")
300+
# "fromisocalendar" was introduced in 3.8
300301
if klass is Timestamp and not compat.PY38:
301302
expected.remove("fromisocalendar")
302303

0 commit comments

Comments
 (0)