@@ -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
0 commit comments