Transform string-based expressions into Polars DataFrame operations
Project description
polars_expr_transformer
polars_expr_transformer
is a Python package designed to simplify the transformation of string-based expressions into Polars DataFrame operations. It enables users to write expressive and readable string-based functions that are automatically converted into Polars expressions for data manipulation and analysis.
Features
- Preprocess Expressions: Preprocess string-based functions to prepare them for transformation.
- Convert to Polars Expressions: Transform preprocessed string expressions into Polars expressions.
- Integrate with Polars DataFrames: Easily apply transformed expressions to Polars DataFrames.
Installation
You can install the package using pip:
pip install polars_expr_transformer
Usage Here's a simplified example of how to use polars_expr_transformer:
from polars_expr_transformer.process.polars_expr_transformer import preprocess, simple_function_to_expr import polars as pl
Define a string-based function
test_func = """'abcd' in 'adbc'"""
Preprocess the function
parsed_test_func = preprocess(test_func)
Create a Polars DataFrame
df = pl.from_dicts([{'a': 'edward', 'b': 'courtney'}, {'a': 'courtney', 'b': 'edward'}])
Apply the transformed expressions to the DataFrame
print(df.select(simple_function_to_expr("'hallo world'"))) License This project is licensed under the MIT License. See the LICENSE file for more details.
Contact For any questions or inquiries, please contact me.
Project details
Release history Release notifications | RSS feed
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
Hashes for polars_expr_transformer-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 579547e61287d2190d94267b36f16776aa733206fcf3cf3499061ce772834826 |
|
MD5 | b126cf4c396bc7becdc1c18e80f85e2b |
|
BLAKE2b-256 | 285df7d1785cbbb597f635a43e6e49ad95b4c137c3bbff09d978d96f7cd277c3 |
Hashes for polars_expr_transformer-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89711a980d2246544b4d112bec425b6b4f2415e9981d766a13b6ba190c9af888 |
|
MD5 | fc28a0398db110c83e91be82d66fec5f |
|
BLAKE2b-256 | db337bcb5659ea8f6f7e50e30dc2d00932ff4b09e16ed589466009ec484b625e |