You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When test-driving the new pandas release candidate 2.0.0rc0 we noticed that generating Plotly graphs failed (snippet for reference below).
When investigating, we found the following in the Plotly code: (x_end - x_start).astype("timedelta64[ms]"). With Pandas < 2 this returned float64 representing the ms between the timestamps.
Now that Pandas 2 has a timedelta64[ms] dtype this dtype is used instead.
[...]
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py:258, in JSONEncoder.iterencode(self, o, _one_shot)
253 else:
254 _iterencode = _make_iterencode(
255 markers, self.default, _encoder, self.indent, floatstr,
256 self.key_separator, self.item_separator, self.sort_keys,
257 self.skipkeys, _one_shot)
--> 258 return _iterencode(o, 0)
File ~/venv/weplan3.11/lib/python3.11/site-packages/_plotly_utils/utils.py:136, in PlotlyJSONEncoder.default(self, obj)
134 except NotEncodable:
135 pass
--> 136 return _json.JSONEncoder.default(self, obj)
File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/encoder.py:180, in JSONEncoder.default(self, o)
161 def default(self, o):
162 """Implement this method in a subclass such that it returns
163 a serializable object for ``o``, or calls the base implementation
164 (to raise a ``TypeError``).
(...)
178
179 """
--> 180 raise TypeError(f'Object of type {o.__class__.__name__} '
181 f'is not JSON serializable')
TypeError: Object of type timedelta is not JSON serializable
The text was updated successfully, but these errors were encountered:
kaibir
changed the title
Creating a timeline does not work with new pandas 2.0.0rc0
Creating a timeline does not work with [new] pandas 2.0.0
Apr 4, 2023
Description:
When test-driving the new pandas release candidate 2.0.0rc0 we noticed that generating Plotly graphs failed (snippet for reference below).
When investigating, we found the following in the Plotly code: (x_end - x_start).astype("timedelta64[ms]"). With Pandas < 2 this returned float64 representing the ms between the timestamps.
Now that Pandas 2 has a timedelta64[ms] dtype this dtype is used instead.
But Plotly expects a float64 dtype and we run into an issue, that timedelta is not JSON serializable (see Plotly reproduction below)
The following works with all Pandas versions (especially 1.5.3 and 2.0.0rc0):
Plotly reproduction (with pandas 2.0.0rc0
leads to
The text was updated successfully, but these errors were encountered: