Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read_json errors when parsing NaN #16245

Open
2 tasks done
twoertwein opened this issue May 15, 2024 · 2 comments
Open
2 tasks done

read_json errors when parsing NaN #16245

twoertwein opened this issue May 15, 2024 · 2 comments
Labels
needs decision Awaiting decision by a maintainer

Comments

@twoertwein
Copy link
Contributor

Checks

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of Polars.

Reproducible example

import json
from io import StringIO

import polars as pl

pl.read_json(StringIO(json.dumps([{"foo": float("nan")}])))

Log output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/twoertwein/miniforge3/lib/python3.10/site-packages/polars/io/json.py", line 94, in read_json
    pydf = PyDataFrame.read_json(
RuntimeError: BindingsError: "InternalError(TapeError) at character 9 ('N')"

Issue description

read_json errors when parsing NaNs.

Expected behavior

read_json can parse NaNs.

Installed versions

--------Version info---------
Polars:               0.20.23
Index type:           UInt32
Platform:             macOS-14.4.1-arm64-arm-64bit
Python:               3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:51:49) [Clang 16.0.6 ]

----Optional dependencies----
adbc_driver_manager:  <not installed>
cloudpickle:          <not installed>
connectorx:           <not installed>
deltalake:            <not installed>
fastexcel:            <not installed>
fsspec:               2024.3.1
gevent:               <not installed>
hvplot:               <not installed>
matplotlib:           3.8.4
nest_asyncio:         <not installed>
numpy:                1.24.3
openpyxl:             <not installed>
pandas:               2.2.1
pyarrow:              <not installed>
pydantic:             <not installed>
pyiceberg:            <not installed>
pyxlsb:               <not installed>
sqlalchemy:           <not installed>
xlsx2csv:             <not installed>
xlsxwriter:           <not installed>
@twoertwein twoertwein added bug Something isn't working needs triage Awaiting prioritization by a maintainer python Related to Python Polars labels May 15, 2024
@tushar-nitave
Copy link

Can I work on this?

@ritchie46
Copy link
Member

NaN isn't part of the JSON spec. So our json parser (external crate) don't parse it.

https://www.json.org/json-en.html

@ritchie46 ritchie46 added needs decision Awaiting decision by a maintainer and removed bug Something isn't working python Related to Python Polars needs triage Awaiting prioritization by a maintainer labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs decision Awaiting decision by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants