BUG: boxing Timedeltas on .apply · Issue #11349 · pandas-dev/pandas (original) (raw)
Consider the following Series:
object_id
0CKVYKjyFn 76 days
0CrPL2QKH3 -15 days
0CrVStlVrg 23 days
0Cc5ZvS67u 76 days
0CTOk5OdtI 76 days
0CTSWtTzBa 76 days
0CwBqVeNCX 76 days
0CIRJFIOcD 58 days
0CRQPCxzQe 350 days
0CAq4m9Nru 15 days
0C617yvXBj 76 days
0CzUUJNKX9 -16 days
Name: days_left, dtype: timedelta64[ns]
I am hoping to convert the above to hours.
If I do:
I get:
AttributeError: 'Series' object has no attribute 'hours
What's even more strange is that if I do:
my_series[0].total_seconds()/3600 1824.0
it works for one element, but if I do:
> my_series.apply(lambda x: x.total_seconds())
I get:
AttributeError: 'numpy.timedelta64' object has no attribute 'total_seconds'
I thought apply
would run the function I pass it item by item in the series. Why does total_seconds()
work for a single item, but not with apply
?