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")

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.1.12-cp313-cp313-win_amd64.whl (812.8 kB view details)

Uploaded CPython 3.13Windows x86-64

colss-0.1.12-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.1.12-cp313-cp313-macosx_15_0_arm64.whl (965.6 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

colss-0.1.12-cp312-cp312-win_amd64.whl (812.7 kB view details)

Uploaded CPython 3.12Windows x86-64

colss-0.1.12-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.1.12-cp312-cp312-macosx_15_0_arm64.whl (965.6 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

colss-0.1.12-cp311-cp311-win_amd64.whl (810.4 kB view details)

Uploaded CPython 3.11Windows x86-64

colss-0.1.12-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.1.12-cp311-cp311-macosx_15_0_arm64.whl (964.0 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

colss-0.1.12-cp310-cp310-win_amd64.whl (810.2 kB view details)

Uploaded CPython 3.10Windows x86-64

colss-0.1.12-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.1.12-cp310-cp310-macosx_15_0_arm64.whl (963.2 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

colss-0.1.12-cp39-cp39-win_amd64.whl (810.7 kB view details)

Uploaded CPython 3.9Windows x86-64

colss-0.1.12-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.1.12-cp39-cp39-macosx_15_0_arm64.whl (963.3 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for colss-0.1.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 6b5f0c7993e59a5679392164eccdfcfa366cb02e1bd70949c80785f4bcee98df
MD5 9302309c0a63cd82f079ef4384fb1085
BLAKE2b-256 d2b9ca85fdf74a86090832b476d954147e22f5506c8e9e60ebfc0cf4318b1f50

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0594c437afec818021ed9f3a8771c52e23ad34dd773ec901cba45914c1b9ed01
MD5 10d4141d37ae347c549847a3bbd9a614
BLAKE2b-256 21b0bb4e911f349e09ca6a4374dec18ae1845c64a4562ca0c59265c83aa9ae90

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 67059f8d0692480a21723fea72994861f53819d2c51b54e4cc6b4a8a0820a8d5
MD5 f466d1b160f5a166d12bc4a384431027
BLAKE2b-256 4a1caff5061a2a2a6eef1cfd8a3c45614e9e4780dfa6819423137f1830c5ccf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp312-cp312-win_amd64.whl.

File metadata

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

File hashes

Hashes for colss-0.1.12-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b64b8eee8df0b3bebc8abcf7ee7ddeedbcea6b1e841592c99c08f24623f13cc2
MD5 2e78540e79d2ae8ce5f18d9c6825d78a
BLAKE2b-256 5e25282c74eab0b731d86a2bff9a4d969b31b48fa926c065244d8c7fe8e5a557

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 586b03fefe9a1d2027736fcfb013e4fb0407259166c53aa6b46afeb139bb6bfb
MD5 60c8b0199f831f0643ba6d33b7725122
BLAKE2b-256 7f56894ef653b3d22fe4103329750506e903c5aa80e4b72fa6406360324ac95e

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1acfae73c92426f25e3140dfbdfa313a2ba93caa78fc1545f06928a9430bad9c
MD5 8fceff136475e8ea424ab94ed799e672
BLAKE2b-256 a8718cb1f426d275b861e6e230b5e8d98df36f6b93cc0d79be441766cba098c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp311-cp311-win_amd64.whl.

File metadata

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

File hashes

Hashes for colss-0.1.12-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d09688ca74a6c32f57990dcd7cab091aaba5b164f377e2095dd661be8e09cb79
MD5 4ac055b1fe2bdd9f8f3c37bfadc44cc5
BLAKE2b-256 b87dd2d82949984f8951c6168f57ca89c1ec3fb68db1dc671bbeb270dc25666d

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9364c2ad9a1af8940d6ee4f02bdf1fe884aba9b821c87a62b8de212c1c8bc5ce
MD5 020513f63dbd8c8bc390762298241c6f
BLAKE2b-256 610611c9c2db639a7c1354e6397b905678c42fc7a6cbfef075cd4f1073ed3fec

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 af7efd46141c292a2be8faa9eaa17e9df5652d7ab6a918f6b705fbedaee03e74
MD5 1fd922cbc3f0be2ade8cea93f19c0840
BLAKE2b-256 998b0f0df95f2fcc65c2cf997f3a51d9efa3c9f4b164f5672adce0991e172196

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp310-cp310-win_amd64.whl.

File metadata

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

File hashes

Hashes for colss-0.1.12-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 63d5d8fbe0f5b3cea6bab77e74d155ecdf7d26ce9c82d932a7dd6503adb4b9b6
MD5 b0aea7e66632a7abbd1c139c71ad5895
BLAKE2b-256 eefc958384d2e00119fddda9caffe8e09048094413398b94a12a509c32a8c750

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e5db640e774732ff763bee754576f451acb50f000c967b6eb957d6e2aa47dad7
MD5 9a022365186f318734655969f314b3a0
BLAKE2b-256 6b2f00be3b69a90003ec956aefadb7e8a1e8387e1f66b7028040de2c3c1883ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp310-cp310-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e19367f86610676b4f6585c77d7b70d1e6557a809bd1a8cdadbb88dc897c70ee
MD5 e11b7a264ef8a6e595f33e82a233fc94
BLAKE2b-256 c5c3f55b3bff1cb3abfe5a8d2277f76cffdabd9a5a11546ba12373e6f22d7134

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp39-cp39-win_amd64.whl.

File metadata

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

File hashes

Hashes for colss-0.1.12-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ed9da5bb83c33d5750c315d10d1a65aefa59570b1f9eefa99a7807452c389580
MD5 0c15d8a5514b3df1cf470e92990089d1
BLAKE2b-256 343ce17f12f3d45248df415fd195da6ff36562c3c86e4fc42397dfe4d0cafec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ac15ae50c656774a82f1a164dceb9b9191eb4a580fcaeff01a1221d106e2860
MD5 d2a03ed3b8ddcc6d67375ae85ae0dc2b
BLAKE2b-256 c766c644d87253253d18eb4dea0f14f86f35e69e626c0219c3fbc1e80204e8bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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.1.12-cp39-cp39-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for colss-0.1.12-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a8e06fe3876f8fb41f5efd809e6d51ba6004f6ea75298bd01fcbc61d203dc039
MD5 5d34b27e37b5d7979cf6e57c1f7a29df
BLAKE2b-256 1cdf55538337cc67df455a4df7fb8999efdca2d9fc9d5862b98c878e4813a01e

See more details on using hashes here.

Provenance

The following attestation bundles were made for colss-0.1.12-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