.dt.total_seconds is basically just multiplication and can be run at numpythonic speed:
def total_seconds(self):
"""
Total duration of each element expressed in seconds.
.. versionadded:: 0.17.0
"""
return self._maybe_mask_results(1e-9 * self.asi8)
If we interrupted the operation days, we will see that it spends its time in the slow list using getattr and constructing Timedelta ( source ) objects :
360 else:
361 result = np.array([getattr(Timedelta(val), m)
--> 362 for val in values], dtype='int64')
363 return result
364
This shouts to me: “Look, let's get it right, and we will move on to the optimization bridge when we get to it.”
source
share