Skip to main content

Less verbose Mathematical exp evaluator for pandas,numpy and polar

Project description

colss

colss is a lightweight expression evaluator that evaluates math-style string expressions on NumPy, Pandas, Polars, and standard Python arrays, reducing verbosity compared to native syntax eg: $\Sigma\left(e^{\sin(a)} + \log^2(b+1) - c^3\right)$

colss.sumof("exp(sin(a)) + log(b+1)^2 - c^3")

Installation

pip install colss

Requirements

All arrays must be 1D, preferably float64, and C-contiguous. If you have a 2D array:

a = a.ravel()

Usage

All functions accept a string expression. Just pass the expression — no need to register variables or pass arrays manually.

query

Evaluates an expression element-wise and returns a NumPy array.

import numpy as np
import colss
a = np.array([1.0, 2.0, 3.0], dtype=np.float64)
b = np.array([4.0, 5.0, 6.0], dtype=np.float64)
colss.query("a + b + 7")
colss.query("a > 1 ? 100 : 0")       # ternary
colss.query("sqrt(a) + sin(b)")
colss.query("a ^ 2")                  # a squared
colss.query("a ^ 2 + b ^ 0.5")       # complex expression

mean

Returns the arithmetic mean of the evaluated expression as a scalar.

colss.mean("a")
colss.mean("a + b")
colss.mean("a ^ 2 + b")

sumof

Returns the sum of the evaluated expression as a scalar.

colss.sumof("a")
colss.sumof("a * 2")
colss.sumof("a + b")

prod

Returns the product of all elements of the evaluated expression as a scalar.

colss.prod("a")
colss.prod("a + 1")
colss.prod("a * b")

median

Returns the median of the evaluated expression as a scalar. For even-length arrays, returns the average of the two middle values.

colss.median("a")
colss.median("a + b")
colss.median("a ^ 2 + b")

sd

Returns the population standard deviation of the evaluated expression as a scalar.

colss.sd("a")
colss.sd("a + b")
colss.sd("sqrt(a) + b ^ 2")

variance

Returns the population variance of the evaluated expression as a scalar.

colss.variance("a")
colss.variance("a + b")
colss.variance("a ^ 2 - b")

NumPy Compatibility

colss.query() returns a NumPy array, so you can directly use NumPy array methods and operations like .mean(), .sum(), .reshape(), .astype(), .max(), .min(), .std(), .var(), and more on the result.

import numpy as np
import colss

a = np.array([1.0, 2.0, 3.0], dtype=np.float64)
b = np.array([4.0, 5.0, 6.0], dtype=np.float64)

colss.query("a + b").mean()
colss.query("a ^ 2").sum()
colss.query("sqrt(a)").reshape((3, 1))
colss.query("a * b").astype(np.float32)
colss.query("a + 5").max()
colss.query("a + b").min()
colss.query("a ^ 2").std()
colss.query("a ^ 2").var()

Using with Pandas

import pandas as pd
import numpy as np
import colss
df = pd.DataFrame({
    "a": [1.0, 2.0, 3.0],
    "b": [4.0, 5.0, 6.0]
})
a = df["a"].to_numpy(dtype=np.float64)
b = df["b"].to_numpy(dtype=np.float64)
df["c"] = colss.query("a + b + 7")
m       = colss.mean("a + b")
med     = colss.median("a")
s       = colss.sd("a + b")

Operators

Operator Description
+ - * / Arithmetic
^ Exponentiation — a ^ 2 raises a to the power of 2
% Modulo
> < >= <= == != Comparison
and or not Logical
condition ? a : b Ternary

Available Functions

abs(x)       sqrt(x)      
log(x)       log10(x)     exp(x)
sin(x)       cos(x)       tan(x)
floor(x)     ceil(x)
min(x, y)    max(x, y)

Notes

  • ^ is exponentiation, not bitwise XOR.
  • All arrays used in an expression must be the same length.
  • You can use both scalar and vector at the same time.
  • A NaN or Inf result raises an error identifying the first offending index.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

colss-0.2.0-cp313-cp313-win_amd64.whl (812.5 kB view details)

Uploaded CPython 3.13Windows x86-64

colss-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

colss-0.2.0-cp313-cp313-macosx_15_0_arm64.whl (966.2 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

colss-0.2.0-cp312-cp312-win_amd64.whl (813.2 kB view details)

Uploaded CPython 3.12Windows x86-64

colss-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

colss-0.2.0-cp312-cp312-macosx_15_0_arm64.whl (966.1 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

colss-0.2.0-cp311-cp311-win_amd64.whl (810.8 kB view details)

Uploaded CPython 3.11Windows x86-64

colss-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

colss-0.2.0-cp311-cp311-macosx_15_0_arm64.whl (964.7 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

colss-0.2.0-cp310-cp310-win_amd64.whl (810.1 kB view details)

Uploaded CPython 3.10Windows x86-64

colss-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

colss-0.2.0-cp310-cp310-macosx_15_0_arm64.whl (963.8 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

colss-0.2.0-cp39-cp39-win_amd64.whl (810.9 kB view details)

Uploaded CPython 3.9Windows x86-64

colss-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

colss-0.2.0-cp39-cp39-macosx_15_0_arm64.whl (963.9 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

Details for the file colss-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: colss-0.2.0-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 812.5 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for colss-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7781155d06ee4a189ee74fdeec607fbfd9fb46af9f2e72a99d43e05bc5c1b0a7
MD5 e7b002e984a793b9760297558c81d7da
BLAKE2b-256 66723c77610a4f5823b1e54b553d9f3369d051007ef0879df1b8cae88352aaac

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp313-cp313-win_amd64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80fe7f38c92c7270023a84f4e1308c42175ce4bebe4598bf452b561e9ece65f4
MD5 80c8dc77fcfed71607fc4db5c6760f21
BLAKE2b-256 4a2ef4937bed25004a97309738f2ed0cc893b0fff575ccbe57c31595527757b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 372867c836e8d72f606100ac1d073c149fda4a247a0096193451ced996fedd3f
MD5 2c0807fa3b8af17eae5b3265d1d2ebf3
BLAKE2b-256 b839281f596a37af8e240026ae75609041f994d731841a9dfa36a45646347272

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp313-cp313-macosx_15_0_arm64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: colss-0.2.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 813.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for colss-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 df794e07a30a18cc3df678d738864c753291671f3f06a2bd6fa5eb4d7299429a
MD5 38b8e8e8186943474a1286c78a656f1d
BLAKE2b-256 a94ee7a02cfad531c1b07855c1ae647cfde55da650be317decdedc9996439e5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp312-cp312-win_amd64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c9e439ccbc9d16bbd67742e4562bf2658b09dda3142c2c3554e1e8c4701edab
MD5 71386a8ed05a583722a065c0c462a519
BLAKE2b-256 eb6171c0d1143dcd3c493c384bb278f15260fd83f40ed2d6e618b59f7bb88599

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 aabe7e3afe5dc94902800252383399a9edc254d36316d6e395ca72cde1266b46
MD5 e1e05c537b88b93adcdc3e4d80969c56
BLAKE2b-256 5734ea471e8b7320dfe2e4569f8a0790c36f612b206fe8590d91dc8b4cad5588

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp312-cp312-macosx_15_0_arm64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: colss-0.2.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 810.8 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for colss-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8741334a20a98553e25856300907aa27bb4f2dbcaccdeed55d5d1ec0e97a05cc
MD5 2569885eb56944f7b045ac67d90a3519
BLAKE2b-256 c2efbf67f34ddd257ac494833797ed17bd15ce36f1da28bee5a588e59ea34dc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp311-cp311-win_amd64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ad60f7f1c068c9c21ab1e8f93c7baca699f77713dc26754d5d2ddfd7b1e2076
MD5 a0c3605d7cc74ffc702e5980c057306b
BLAKE2b-256 fcd6e1219d74c55202f4fb54a005072d8a5fdf5ccb33e2ec284dae4e1e00209d

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 0bb36d9bc6edc3c6bd225c23149a1358295de478e83450cff05a8a96595aa04b
MD5 20880c6118ad3d8f7e16104c5332a69f
BLAKE2b-256 2c1a05d8e2d5efaf58a9abc7e20fa161e758c215e9f121e4fb647163f96ccac2

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp311-cp311-macosx_15_0_arm64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: colss-0.2.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 810.1 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for colss-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 68fd1596466342c1514dd0c6556650b2660341accd47194edd783f41b21b96c9
MD5 46209687d22f4598410c245b6718ae35
BLAKE2b-256 8e8ece4976d5ed2b91fcab3302738ba739eb058109fe9429700daab835957d2b

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp310-cp310-win_amd64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1db79cce2f83baa8c253ba2f399b1afbf99011ad8ab3c1eb735ec3d2f018baa1
MD5 a8631c94d624a1cf31cdd6488e084908
BLAKE2b-256 16e9a78594246effe514f3065ddd8e37142c9cadf905d91545db1d97a7955785

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 5519af521be6a61f9fe010869acbe692a7f5d67a8a63ce28901b38347f2b902d
MD5 c81507849ee39bd40cfb9477dc8447ab
BLAKE2b-256 1af6a2821a4a688a01c66e946e56cff80cffe508a907e425309145c2c159fb10

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp310-cp310-macosx_15_0_arm64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: colss-0.2.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 810.9 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for colss-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a410978a9101e15ec01830f7021242e0d263e96cfe47ef16c4226e8cea26616f
MD5 93f3a5d04431ac7d721f34395901ce98
BLAKE2b-256 d0145ecb9983439e8c8c3f642ffe3c431d056b2c2766866aea6b6b59370c643c

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp39-cp39-win_amd64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a51e6c14fc16d75567b9b95be3d033c0da1cbe868ceaab291271ce1f1721ba57
MD5 a5a5890d7631eb93b4293ecfeb855678
BLAKE2b-256 a42c2ebf976adb094dd92b6e1299468264c5cbdb3d3e099d1b4c253d2c5619dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file colss-0.2.0-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

  • Download URL: colss-0.2.0-cp39-cp39-macosx_15_0_arm64.whl
  • Upload date:
  • Size: 963.9 kB
  • Tags: CPython 3.9, macOS 15.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for colss-0.2.0-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1ed5e036ca0720ce101c24c4d3f210f88696b34c0eceaf254b31d97de0c6ecd1
MD5 5df2bf99e94afa22bddc05696849529b
BLAKE2b-256 d321f495318d40a80f96789881eb8c817312df2113e99b48fd123d31f1d3131e

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.2.0-cp39-cp39-macosx_15_0_arm64.whl:

Publisher: wheels.yml on SivaPA08/colss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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