@@ -1038,6 +1038,25 @@ cdef class _Timedelta(timedelta):
1038
1038
1039
1039
@property
1040
1040
def value (self ):
1041
+ """
1042
+ Return the value of Timedelta object in nanoseconds.
1043
+
1044
+ Return the total seconds, milliseconds and microseconds
1045
+ of the timedelta as nanoseconds.
1046
+
1047
+ Returns
1048
+ -------
1049
+ int
1050
+
1051
+ See Also
1052
+ --------
1053
+ Timedelta.unit : Return the unit of Timedelta object.
1054
+
1055
+ Examples
1056
+ --------
1057
+ >>> pd.Timedelta(1, "us").value
1058
+ 1000
1059
+ """
1041
1060
try :
1042
1061
return convert_reso(self ._value, self ._creso, NPY_FR_ns, False )
1043
1062
except OverflowError :
@@ -1120,6 +1139,37 @@ cdef class _Timedelta(timedelta):
1120
1139
def microseconds (self ) -> int: # TODO(cython3 ): make cdef property
1121
1140
# NB: using the python C-API PyDateTime_DELTA_GET_MICROSECONDS will fail
1122
1141
# (or be incorrect)
1142
+ """
1143
+ Return the number of microseconds (n), where 0 <= n < 1 millisecond.
1144
+
1145
+ Timedelta.microseconds = milliseconds * 1000 + microseconds.
1146
+
1147
+ Returns
1148
+ -------
1149
+ int
1150
+ Number of microseconds.
1151
+
1152
+ See Also
1153
+ --------
1154
+ Timedelta.components : Return all attributes with assigned values
1155
+ (i.e. days, hours, minutes, seconds, milliseconds, microseconds,
1156
+ nanoseconds).
1157
+
1158
+ Examples
1159
+ --------
1160
+ **Using string input**
1161
+
1162
+ >>> td = pd.Timedelta('1 days 2 min 3 us')
1163
+
1164
+ >>> td.microseconds
1165
+ 3
1166
+
1167
+ **Using integer input**
1168
+
1169
+ >>> td = pd.Timedelta(42, unit='us')
1170
+ >>> td.microseconds
1171
+ 42
1172
+ """
1123
1173
self ._ensure_components()
1124
1174
return self ._ms * 1000 + self ._us
1125
1175
@@ -1141,6 +1191,26 @@ cdef class _Timedelta(timedelta):
1141
1191
1142
1192
@property
1143
1193
def unit(self ) -> str:
1194
+ """
1195
+ Return the unit of Timedelta object.
1196
+
1197
+ The unit of Timedelta object is nanosecond , i.e., 'ns' by default.
1198
+
1199
+ Returns
1200
+ -------
1201
+ str
1202
+
1203
+ See Also
1204
+ --------
1205
+ Timedelta.value : Return the value of Timedelta object in nanoseconds.
1206
+ Timedelta.as_unit : Convert the underlying int64 representation to
1207
+ the given unit.
1208
+
1209
+ Examples
1210
+ --------
1211
+ >>> td = pd.Timedelta(42 , unit = ' us' )
1212
+ 'ns'
1213
+ """
1144
1214
return npy_unit_to_abbrev(self._creso )
1145
1215
1146
1216
def __hash__(_Timedelta self ):
0 commit comments