From 0d258f4a06baa1d220cccc998f042b522b4d418e Mon Sep 17 00:00:00 2001 From: Dev Aggarwal Date: Mon, 5 Feb 2024 21:27:43 +0530 Subject: [PATCH] fix AttributeError: Can only use .dt accessor with datetimelike values --- recipes/VideoBotsStats.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/VideoBotsStats.py b/recipes/VideoBotsStats.py index c18683b96..00c7f07dd 100644 --- a/recipes/VideoBotsStats.py +++ b/recipes/VideoBotsStats.py @@ -546,9 +546,11 @@ def calculate_stats_binned_by_time( ) * 100 df["Msgs_per_convo"] = df["Messages_Sent"] / df["Convos"] df["Msgs_per_user"] = df["Messages_Sent"] / df["Senders"] - df["Average_response_time"] = ( - df["Average_response_time"].dt.total_seconds() * factor - ) + try: + df["Average_response_time"] = df["Average_response_time"].dt.total_seconds() + except AttributeError: + pass + df["Average_response_time"] = df["Average_response_time"] * factor df.fillna(0, inplace=True) df = df.round(0).astype("int32", errors="ignore") return df