I want to convert my days format to seconds in pandas

Viewed 302

In my dataframe I made a column for average delay which was the mean of a company's delay for clearing a certain amount. Since my average delay and delay contained negative values like -3 days , I was hoping that when I convert my average delay to seconds it will be negative too but it was positive. what did I do wrong?

avg_delay = maindata.groupby('name_customer')['delay'].mean(numeric_only=False)    


maindata['avg_delay'] = maindata['avg_delay'].dt.seconds      
1 Answers

It might be because the .dt.seconds return at max 86400 seconds by the pandas documentation

.dt.total_seconds() might do the job, returning it as float64

Related