Skip to content

Commit d95b306

Browse files
dcreekpjreback
authored andcommitted
DOC: fix timestamp timedelta quotes (#25118)
1 parent cb89bc0 commit d95b306

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

pandas/_libs/tslibs/nattype.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ cdef class _NaT(datetime):
229229

230230
def total_seconds(self):
231231
"""
232-
Total duration of timedelta in seconds (to ns precision)
232+
Total duration of timedelta in seconds (to ns precision).
233233
"""
234234
# GH#10939
235235
return np.nan

pandas/_libs/tslibs/timedeltas.pyx

+27-6
Original file line numberDiff line numberDiff line change
@@ -815,13 +815,29 @@ cdef class _Timedelta(timedelta):
815815

816816
cpdef timedelta to_pytimedelta(_Timedelta self):
817817
"""
818-
return an actual datetime.timedelta object
819-
note: we lose nanosecond resolution if any
818+
Convert a pandas Timedelta object into a python timedelta object.
819+
820+
Timedelta objects are internally saved as numpy datetime64[ns] dtype.
821+
Use to_pytimedelta() to convert to object dtype.
822+
823+
Returns
824+
-------
825+
datetime.timedelta or numpy.array of datetime.timedelta
826+
827+
See Also
828+
--------
829+
to_timedelta : Convert argument to Timedelta type.
830+
831+
Notes
832+
-----
833+
Any nanosecond resolution will be lost.
820834
"""
821835
return timedelta(microseconds=int(self.value) / 1000)
822836

823837
def to_timedelta64(self):
824-
""" Returns a numpy.timedelta64 object with 'ns' precision """
838+
"""
839+
Return a numpy.timedelta64 object with 'ns' precision.
840+
"""
825841
return np.timedelta64(self.value, 'ns')
826842

827843
def to_numpy(self, dtype=None, copy=False):
@@ -846,17 +862,21 @@ cdef class _Timedelta(timedelta):
846862

847863
def total_seconds(self):
848864
"""
849-
Total duration of timedelta in seconds (to ns precision)
865+
Total duration of timedelta in seconds (to ns precision).
850866
"""
851867
return self.value / 1e9
852868

853869
def view(self, dtype):
854-
""" array view compat """
870+
"""
871+
Array view compatibility.
872+
"""
855873
return np.timedelta64(self.value).view(dtype)
856874

857875
@property
858876
def components(self):
859-
""" Return a Components NamedTuple-like """
877+
"""
878+
Return a components namedtuple-like.
879+
"""
860880
self._ensure_components()
861881
# return the named tuple
862882
return Components(self._d, self._h, self._m, self._s,
@@ -1157,6 +1177,7 @@ class Timedelta(_Timedelta):
11571177
-----
11581178
The ``.value`` attribute is always in ns.
11591179
"""
1180+
11601181
def __new__(cls, object value=_no_input, unit=None, **kwargs):
11611182
cdef _Timedelta td_base
11621183

pandas/_libs/tslibs/timestamps.pyx

+4-3
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,8 @@ cdef class _Timestamp(datetime):
539539

540540

541541
class Timestamp(_Timestamp):
542-
"""Pandas replacement for datetime.datetime
542+
"""
543+
Pandas replacement for python datetime.datetime object.
543544
544545
Timestamp is the pandas equivalent of python's Datetime
545546
and is interchangeable with it in most cases. It's the type used
@@ -549,9 +550,9 @@ class Timestamp(_Timestamp):
549550
Parameters
550551
----------
551552
ts_input : datetime-like, str, int, float
552-
Value to be converted to Timestamp
553+
Value to be converted to Timestamp.
553554
freq : str, DateOffset
554-
Offset which Timestamp will have
555+
Offset which Timestamp will have.
555556
tz : str, pytz.timezone, dateutil.tz.tzfile or None
556557
Time zone for time which Timestamp will have.
557558
unit : str

0 commit comments

Comments
 (0)