From 7573ef0c909795d54786506e7ddc8213dad5a9e2 Mon Sep 17 00:00:00 2001 From: Qiusheng Wu Date: Thu, 29 Jun 2023 00:13:44 -0400 Subject: [PATCH] Fix add_gdf bug --- leafmap/leafmap.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/leafmap/leafmap.py b/leafmap/leafmap.py index 8e73ff607a..8be04858f2 100644 --- a/leafmap/leafmap.py +++ b/leafmap/leafmap.py @@ -2475,8 +2475,11 @@ def add_gdf( encoding (str, optional): The encoding of the GeoDataFrame. Defaults to "utf-8". """ for col in gdf.columns: - if gdf[col].dtype in ["datetime64[ns]", "datetime64[ns, UTC]"]: - gdf[col] = gdf[col].astype(str) + try: + if gdf[col].dtype in ["datetime64[ns]", "datetime64[ns, UTC]"]: + gdf[col] = gdf[col].astype(str) + except Exception as e: + print(e) data = gdf_to_geojson(gdf, epsg="4326")