geopandas / geopandas

Python tools for geographic data
http://geopandas.org/
BSD 3-Clause "New" or "Revised" License
4.34k stars 907 forks source link

BUG: support datetime in named index in explore() #3360

Closed martinfleis closed 1 day ago

martinfleis commented 3 days ago

As per @anitagraser's report in #2378, this snippet caused JSON serialisation error even though we say we support datetime.

import pandas as pd
import shapely
import geopandas as gpd

df = gpd.GeoDataFrame(
    index=[pd.Timestamp("2018-01-01 12:02:00"), pd.Timestamp("2018-01-02 12:02:00")],
    geometry=[shapely.Point(0, 0), shapely.Point(2, 0)],
)
df.index.name = "t"
df.explore()

Interestingly enough, non-named datetime index was fine. Only named caused issues.

Fixed by explicitly checking for index dtype and converting as we do with columns.

martinfleis commented 1 day ago

Given @jorisvandenbossche is away, I am not going to wait for a review and merge so we can cut 1.0.1 fixing #3362 regression.