Skip to main content

String-powered Polars expression engine with extended DataFrame utilities

Project description

Polynx logo

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.14.tar.gz (16.9 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.14-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polynx-0.1.14.tar.gz
  • Upload date:
  • Size: 16.9 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.14.tar.gz
Algorithm Hash digest
SHA256 8e345779846b232e278cc90fa41c974725259682fad9bb0ccf4fa3c5eaf37a7b
MD5 7f528d0e37b248250ce45866810bd743
BLAKE2b-256 dfb8c25faa7f00d7636538d4964877ec986269995c1cd91cabc9cfc376c021f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: polynx-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 17.9 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.14-py3-none-any.whl
Algorithm Hash digest
SHA256 368c2da071dc4cda73b33bbcb5cbb6cc2b6f11a642b592f614f3341ca2ac3459
MD5 c83f048862a9e02a3a90c94ac7e7e351
BLAKE2b-256 b97e411bb279f89fc2e101691b6c5c7ddbe1c04de620d8735ebf32491ad8580d

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