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.1.tar.gz (13.5 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.1-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polynx-0.1.1.tar.gz
  • Upload date:
  • Size: 13.5 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.1.tar.gz
Algorithm Hash digest
SHA256 3d6b9b2bb22e42ca92b66b8dfb17a937718bd24c36f94b9cc075e55ce8db04a6
MD5 322dc4de679dc42083fecdb0a8ebdc81
BLAKE2b-256 e3abb907d15da34aaa33c12570e22e5af3a42a813595056a4eae4625168928fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: polynx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 14.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ed8e2237d82e7dc38850c30fda4282133eb2ba8b706e5f7cc7f96351fe5f055c
MD5 d75f72a570896c445a9570152a920666
BLAKE2b-256 9645312bdbc82756df93cbc2af33ab10bce2265be6882ca59d74ead0b2671499

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