Skip to content

Commit

Permalink
clean_time_cols should check if we're already a timestamp column
Browse files Browse the repository at this point in the history
  • Loading branch information
atmorling committed Nov 18, 2024
1 parent 1277d5f commit 599e6bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ecoscope/io/earthranger_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 599e6bf

Please sign in to comment.