Skip to content
Prev Previous commit
Next Next commit
Add doc string to NaT and Timestamp
  • Loading branch information
saurav-chakravorty committed Feb 13, 2019
commit edb629e0d845b00d45dac2d3dbaa211c69ab950e
10 changes: 9 additions & 1 deletion pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ class NaTType(_NaT):
utctimetuple = _make_error_func('utctimetuple', datetime)
timetz = _make_error_func('timetz', datetime)
timetuple = _make_error_func('timetuple', datetime)
strptime = _make_error_func('strptime', datetime)
strftime = _make_error_func('strftime', datetime)
isocalendar = _make_error_func('isocalendar', datetime)
dst = _make_error_func('dst', datetime)
Expand All @@ -368,6 +367,15 @@ class NaTType(_NaT):
# The remaining methods have docstrings copy/pasted from the analogous
# Timestamp methods.

strptime = _make_error_func('strptime',
"""
Timestamp.strptime(string, format)

Function is not implemented as the behavior of datetime.strptime()
differs in Python 2 and Python 3.
"""
)

utcfromtimestamp = _make_error_func('utcfromtimestamp', # noqa:E128
"""
Timestamp.utcfromtimestamp(ts)
Expand Down
6 changes: 6 additions & 0 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,12 @@ class Timestamp(_Timestamp):
# Issue 25016. As strptime with %z is not supported in Python 2.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're dropping Python 2 in the next release, so I don't think this comment is needed.

@classmethod
def strptime(cls, date_string, format):
"""
Timestamp.strptime(string, format)

Function is not implemented as the behavior of datetime.strptime()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of this sentence just mention to use pd.to_datetime instead.

differs in Python 2 and Python 3.
"""
raise NotImplementedError("Timestamp.strptime() is not implmented."
"Use to_datetime() to parse date strings.")

Expand Down