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

Uploaded Python 3

File details

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

File metadata

  • Download URL: polynx-0.1.4.tar.gz
  • Upload date:
  • Size: 14.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.4.tar.gz
Algorithm Hash digest
SHA256 77a39f628de254c4ca27dce9e6f22ea61d0853bcf06d2f0475c8816624aae678
MD5 89d7373c83a5597b757a94c6ae9a39f6
BLAKE2b-256 34fb3f59cafefc87df3ecfae65a27bf9ec78913ae8084b2010da3186798c1375

See more details on using hashes here.

File details

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

File metadata

  • Download URL: polynx-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 15.3 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 151dd503014aa1ee4b7b1e335da2970acbbf90c606e085fe4f5183444cf082e1
MD5 3f22d3bd24b39930d775697562f91d8c
BLAKE2b-256 9a552c222f6f9231e36c535ac0f832e4f1ad28046e20d6ab03efe3e23a35af49

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