Skip to content

Commit 156559d

Browse files
authored
Merge branch 'main' into merge-docs-changes-to-main
2 parents 037956a + a6ee27c commit 156559d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [6.0.1] - 2025-02-16
6+
7+
### Fixed
8+
- Fix `TypeError` when using `orjson` to serialize `pandas.NA`.
9+
510
## [6.0.0] - 2025-01-28
611

712
### Added

plotly/io/_json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ def clean_to_json_compatible(obj, **kwargs):
529529

530530
# pandas
531531
if pd is not None:
532-
if obj is pd.NaT:
532+
if obj is pd.NaT or obj is pd.NA:
533533
return None
534534
elif isinstance(obj, (pd.Series, pd.DatetimeIndex)):
535535
if numpy_allowed and obj.dtype.kind in ("b", "i", "u", "f"):

tests/test_io/test_to_from_plotly_json.py

+6
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,9 @@ def test_sanitize_json(engine):
260260
for bad, good in replacements.items():
261261
assert bad not in fig_json
262262
assert good in fig_json
263+
264+
265+
@pytest.mark.parametrize("na_value", [np.nan, pd.NaT, pd.NA])
266+
def test_na_values(engine, na_value):
267+
result = pio.to_json_plotly(na_value, engine=engine)
268+
assert result == "null"

0 commit comments

Comments
 (0)