A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11349 below:

GitHub ยท Where software is built

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?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4