Skip to content

to_json index with Null Value Broken in 1.0 #31801

Open
@WillAyd

Description

@WillAyd

Discovered by @ArtificialQualia in #31748

Previous behavior on 0.25.3:

>>> pd.Series([1], index=[np.nan]).to_json()
'{"null":1}'
>>> pd.Series([1], index=[pd.NaT]).to_json()
'{"null":1}'
>>> pd.Series([1], index=[None]).to_json()
'{"null":1}'

And now on master:

>>> pd.Series([1], index=[np.nan]).to_json()
'{"nan":1}'
>>> pd.Series([1], index=[pd.NaT]).to_json()
'{"null":1}'
>>> pd.Series([1], index=[None]).to_json()
'{"None":1}'

Note that pd.NA also just has its str representation written out:

>>> pd.Series([1], index=[pd.NA]).to_json()
'{"<NA>":1}'

pd.NaT still works because of this logic:

if (nanosecVal == get_nat()) {

So probably need to generalize for other "null" values

Metadata

Metadata

Assignees

Labels

BugIO JSONread_json, to_json, json_normalizeRegressionFunctionality that used to work in a prior pandas version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions