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

feat(python): Add simple version of json_normalize #17015

Merged
merged 4 commits into from
Jun 17, 2024
Merged

Conversation

ritchie46
Copy link
Member

This adds a json_normalize function forked and adapted from pandas. There are some changes, as we will never return an pl.Object type for objects that are not normalized. These will be encoded as json strings, so that we will get a string column and not objects.

Features we have over the pandas counterpart is that we allow the user to set the schema.

Furthermore we don't have all the features, but this should already be useful for the most common cases.

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jun 17, 2024
Copy link
Member

@stinodego stinodego left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say this isn't technically I/O functionality - it's "convert" functionality since it starts from an in-memory representation. It should be in the convert.py module next to from_arrow, from_numpy, etc.

Also, I'd suggest marking this as unstable for now.

Copy link

codecov bot commented Jun 17, 2024

Codecov Report

Attention: Patch coverage is 71.66667% with 17 lines in your changes missing coverage. Please review.

Project coverage is 81.04%. Comparing base (a81f6a5) to head (951b9a4).
Report is 9 commits behind head on main.

Files Patch % Lines
py-polars/polars/convert/normalize.py 69.09% 10 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17015      +/-   ##
==========================================
+ Coverage   81.03%   81.04%   +0.01%     
==========================================
  Files        1446     1449       +3     
  Lines      190420   190482      +62     
  Branches     2709     2722      +13     
==========================================
+ Hits       154299   154370      +71     
+ Misses      35624    35609      -15     
- Partials      497      503       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ritchie46 ritchie46 merged commit 5d0aba8 into main Jun 17, 2024
14 checks passed
@ritchie46 ritchie46 deleted the json_normalize branch June 17, 2024 12:05
@c-peters c-peters added the accepted Ready for implementation label Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants