-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Load JSON object from string with nested array. #3404
Comments
It looks like the type that is inferred is an object instead of a list of structs. I'm actually working on a Rust solution for parsing JSON (#3373 and jorgecarleitao/arrow2#989) that will work with |
Hi, thanks for the quick response. I tired
|
Thanks for your work. I have one more question. The following code works import polars as pl
df = pl.DataFrame(
{"text": ['[{"x": 1, "y": 2}]', '[{"x": 1, "y": 2}, {"x": 3, "y": 4}]']}
)
df.select(pl.col("text").apply(json.loads)) while the following code fails import polars as pl
df = pl.DataFrame(
{"text": ['[{"x": 1, "y": 2}, {"x": 3, "y": 4}]', "[]"]}
)
df.select(pl.col("text").apply(json.loads)) Is |
I can't reproduce the issue -- try using the latest release. |
This has been fixed in #3433 . But the following code still does not work import polars as pl
df = pl.DataFrame(
{"text": ['[]', '[{"x": 1, "y": 2}, {"x": 3, "y": 4}]', '[{"x": 1, "y": 2}]']}
)
df.select(pl.col("text").apply(json.loads)) Note that the |
Thanks for raising this. I think the issue is that polars is not correctly combining the schemas. Can you raise this as a separate issue so it gets more visibility? |
Done! #3478 |
What language are you using?
Python
Which feature gates did you use?
Load JSON object from string with nested array.
Have you tried latest version of polars?
Yes
What version of polars are you using?
0.13.34
What operating system are you using polars on?
macOS 12.3.1
What language version are you using
Python 3.8.13
Describe your bug.
Applying
json.loads
to string column with text like'[{"x": 1, "y": 2}, {"x": 3, "y": 4}]'
givesPanicException
.What are the steps to reproduce the behavior?
What is the actual behavior?
What is the expected behavior?
Should be no error.
The text was updated successfully, but these errors were encountered: