Modifying/extending jsonEncoder for panda dataframe timespan objects

Thanks for the response. I did a little digging, and it’s possible to recast Period objects in pandas into Timestamp objects using the to_timestamp() method in Period. Once you have a Timestamp object, then plotly’s JSON Encoder will do the right thing and use the object’s isoformat() method (cf. PlotlyJSONEncoder.encode_as_datetime().

It looks like the to_timestamp() method uses the initial (start) of a Period object when building the Timestamp object, so pd.Period('2012-05', freq='D').to_timestamp() yields Timestamp('2012-05-01 00:00:00'), and PlotlyJSONEncoder().encode(pd.Period('2012-05', freq='D').to_timestamp()) returns '"2012-05-01"'.

This seems like the best workaround for now.