From 599e6bf60b462f2363532ded359c6bf74f97ec61 Mon Sep 17 00:00:00 2001 From: Alex Morling Date: Mon, 18 Nov 2024 14:01:06 +0200 Subject: [PATCH] clean_time_cols should check if we're already a timestamp column --- ecoscope/io/earthranger_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecoscope/io/earthranger_utils.py b/ecoscope/io/earthranger_utils.py index eff34e64..a8fc7ea8 100644 --- a/ecoscope/io/earthranger_utils.py +++ b/ecoscope/io/earthranger_utils.py @@ -39,7 +39,7 @@ def to_gdf(df): def clean_time_cols(df): time_cols = ["time", "created_at", "updated_at", "end_time", "last_position_date", "recorded_at", "fixtime"] for col in time_cols: - if col in df.columns: + if col in df.columns and not pd.api.types.is_datetime64_ns_dtype(df[col]): # convert x is not None to pd.isna(x) is False df[col] = df[col].apply(lambda x: pd.to_datetime(parser.parse(x), utc=True) if not pd.isna(x) else None) return df