-1
I have a Dataframe in which one of the columns is the time interval in days between the search from one row to another, the data of this column are in the Timedelta form, as in the example: Timedelta('61 days 00:00:00')
I need to convert this column to Float in order to operate it
I tried to convert as follows:
i = 1
ts= df_h['Intervalo Pesquisa'][i].total_seconds()
ts
That works perfectly and returns me a float, but when I put the function inside a for, it does not rotate:
td_list = []
for i in range (8410):
ts= df_h['Intervalo Pesquisa'][i].total_seconds()
td = ts/86400 #dividir total de segundos pelos segundos de um dia
td_list.append(td)
Returns me the following error:
AttributeError Traceback (most recent call last)
<ipython-input-88-99d7df4ff6da> in <module>()
1 td_list = []
2 for i in range (8410):
----> 3 ts= df_h['Intervalo Pesquisa'][i].total_seconds()
4 td = ts/86400 #dividir total de segundos pelos segundos de um dia
5 td_list.append(td)
AttributeError: 'int' object has no attribute 'total_seconds'
I don’t know why it’s not working.
I accept suggestions for other methods to convert Timedelta to Float