Package short description.
Project description
Welcome to jsonpolars Documentation
jsonpolars is an innovative Python library designed to bridge the gap between JSON-based data manipulation syntax and the powerful Polars data processing library. This project aims to provide a flexible and intuitive way to express Polars operations using JSON structures, making it easier for developers to work with Polars in various contexts. The library allows users to define complex data transformations using JSON syntax, which can then be translated into native Polars operations.
Example:
import polars as pl
from jsonpolars.api import parse_dfop
df = pl.DataFrame(
[
{"id": 1, "firstname": "Alice", "lastname": "Smith"},
{"id": 2, "firstname": "Bob", "lastname": "Johnson"},
{"id": 3, "firstname": "Cathy", "lastname": "Williams"},
]
)
dfop_data = {
"type": "with_columns",
"exprs": [
{
"type": "alias",
"name": "fullname",
"expr": {
"type": "plus",
"left": {"type": "column", "name": "firstname"},
"right": {
"type": "plus",
"left": {
"type": "lit",
"value": " ",
},
"right": {"type": "column", "name": "lastname"},
},
},
}
],
}
op = parse_dfop(dfop_data)
df1 = op.to_polars(df)
print(df1)
Output:
shape: (3, 4)
┌─────┬───────────┬──────────┬────────────────┐
│ id ┆ firstname ┆ lastname ┆ fullname │
│ --- ┆ --- ┆ --- ┆ --- │
│ i64 ┆ str ┆ str ┆ str │
╞═════╪═══════════╪══════════╪════════════════╡
│ 1 ┆ Alice ┆ Smith ┆ Alice Smith │
│ 2 ┆ Bob ┆ Johnson ┆ Bob Johnson │
│ 3 ┆ Cathy ┆ Williams ┆ Cathy Williams │
└─────┴───────────┴──────────┴────────────────┘
Install
jsonpolars is released on PyPI, so all you need is to:
$ pip install jsonpolars
To upgrade to latest version:
$ pip install --upgrade jsonpolars
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file jsonpolars-0.2.1.tar.gz
.
File metadata
- Download URL: jsonpolars-0.2.1.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfc2267d8638532de38c0130ddbc5e323c86c48da7a13917355ede7b4264a6e6 |
|
MD5 | 64bc2f547e525ebc713d788fc7447cfc |
|
BLAKE2b-256 | 8babe684bc0125d9fe99211fe2ea7796539f2c50f7b6528fe4c45a1039d565d8 |
File details
Details for the file jsonpolars-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: jsonpolars-0.2.1-py3-none-any.whl
- Upload date:
- Size: 34.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 061297110e20649535caa5c99f74df921201bc08a5757b1dee86c6ebf6adf29d |
|
MD5 | 64ccbc4889d93a6bb18d6f58fb671841 |
|
BLAKE2b-256 | 0759c91e8760fa19330bb24d6546a8f6e4f2161f5ce235d774a485a7eebbda4b |