Skip to main content

String-powered Polars expression engine with extended DataFrame utilities

Project description

Polynx

String-powered Polars expression engine with extended DataFrame utilities.

Table of Contents

Installation

Via PyPI (Recommended)

Install using pip:

pip install polynx

From Souce

Clone the repository and install using pip:

git clone https://github.com/LowellWinston/polynx.git
cd polynx
pip install .

Usage

import polynx as plx
  • Supports all polars functions
df = plx.DataFrame({
    'A':[1, 2, 3, 4], 
    'B': ['abc', 'bc', 'aaa', None], 
    'C': ['2023-01-01','2021-01-01','2009-11-01','2000-11-11'],
    'E': [1.1, 2.1, 3.5, 0]}
).wc("C.str.to_datetime(format='%Y-%m-%d',time_unit='ns').dt.date()")

df
ABCE
i64strdatef64
1"abc"2023-01-011.1
2"bc"2021-01-012.1
3"aaa"2009-11-013.5
4null2000-11-110.0
  • Pandas style query function with chaind comparison, variable substituion in string expression
var1 = 1
var2 = 3
var3 = ['bc']
query_str =  "@var1 <= A < @var2 & C.dt.year() >=2020 & B in @var3"
df.query(query_str)
ABCE
i64strdatef64
2"bc"2021-01-012.1
  • String operation
query_str = "B.str.contains('a|b')"
#query_str = " B.str.ends_with('c')"
df.query(query_str)
ABCE
i64strdatef64
1"abc"2023-01-011.1
2"bc"2021-01-012.1
3"aaa"2009-11-013.5
  • Year month comparison in string format
var5 ='2001-01-01'
var3 = '2020-01-01'
query_str = " @var5 < C < @var3 "
df.query(query_str)
ABCE
i64strdatef64
2"bc"2021-01-012.1
  • in and not in
query_str = " B in ['aaa','bc']"
df.query(query_str)
ABCE
i64strdatef64
2"bc"2021-01-012.1
3"aaa"2009-11-013.5
  • Math calcuation
query_str = " A ** 2 - E > 1"
df.query(query_str)
ABCE
i64strdatef64
2"bc"2021-01-012.1
3"aaa"2009-11-013.5
4null2000-11-110.0
  • Pandas style eval function
query_str = " (A ** 2 - E)/(10-A)"
df.eval(query_str)
A
f64
-0.011111
0.2375
0.785714
2.666667
  • negation
query_str = " not (B.is_null() & A.is_not_null())"
df.query(query_str)
ABCE
i64strdatef64
1"abc"2023-01-011.1
2"bc"2021-01-012.1
3"aaa"2009-11-013.5
  • wc extends with_columns to support multipe statement assignments
df.wc("A.sum().over('B').alias('H'); E.mean().alias('E_mean')")
ABCEHE_mean
i64strdatef64i64f64
1"abc"2023-01-011.111.675
2"bc"2021-01-012.121.675
3"aaa"2009-11-013.531.675
4null2000-11-110.041.675
  • Extend describe for group by
df.describe(group_keys='B', selected_columns=['A','E']).round()
  • Extend group_by to work with string expressions
df.gb('B', " A.sum(); E.mean()")
BAE
strf64f64
null4.00.0
"aaa"3.03.5
"abc"1.01.1
"bc"2.02.1
  • Support lazyframe
df.lazy().wc("E = 1").collect()
ABCE
i64strdatei32
1"abc"2023-01-011
2"bc"2021-01-011
3"aaa"2009-11-011
4null2000-11-111

Features

  • String-powered expression engine for Polars DataFrames
  • Support for complex mathematical and statistical operations
  • Easy-to-use syntax for powerful data manipulation
  • Fast and scalable, optimized for large datasets

Documentation

TO BE UPDATED.

Contributing

We welcome contributions! If you'd like to help improve this project, please fork the repository, make your changes, and submit a pull request.

LICENSES

This project is licensed under the MIT License - see the LICENSE file for details.

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

polynx-0.1.3.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polynx-0.1.3-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

Details for the file polynx-0.1.3.tar.gz.

File metadata

  • Download URL: polynx-0.1.3.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for polynx-0.1.3.tar.gz
Algorithm Hash digest
SHA256 8f3057aaf28c8befd0172964bfc2b296afdae38bb87bd65f7f52bddad097dccd
MD5 4fdb27ec13bd5d241d7682583713632f
BLAKE2b-256 3719839c52823730d9218491073ef81cfb4f223bc9bdf0cfb251e69afbb50af3

See more details on using hashes here.

File details

Details for the file polynx-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: polynx-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.1

File hashes

Hashes for polynx-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 136c7899fc86e1f2a3b891b53f3d497c82901be29fc2afdd311fef40a8bbac7a
MD5 5fb87bde7a49c2d0e09d3f305216740c
BLAKE2b-256 add649befd5335766774ba37a4746258e1796b3613ec1d227f74e564736a6b53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page