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

Uploaded Python 3

File details

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

File metadata

  • Download URL: polynx-0.1.10.tar.gz
  • Upload date:
  • Size: 14.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.10.tar.gz
Algorithm Hash digest
SHA256 2c875321c64d8a905dc2618ad196f1957b7bb390107081e8aaab4b1077a1bf41
MD5 90850cb5e9315ab80e509d4cac8960e5
BLAKE2b-256 9919b6d79e115ed1551375f36f5ae6b1822c2868d1363a7bb696a45624d2594c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: polynx-0.1.10-py3-none-any.whl
  • Upload date:
  • Size: 15.7 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.10-py3-none-any.whl
Algorithm Hash digest
SHA256 5e2232ba6e0dcbb798ab20de331e4e68ba8ae2f2c559c816358fecdda3c9362f
MD5 1d4cdd175e3e22cb333ea241d0f447ec
BLAKE2b-256 7f1cd667b5541b766f2a8a1bc845b3eb8d9808f581dea9d87c77459e1d82e579

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