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.sum("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")

sum

Returns the sum of the evaluated expression as a scalar.

colss.sum("a")
colss.sum("a * 2")
colss.sum("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.11-cp313-cp313-win_amd64.whl (812.6 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

colss-0.1.11-cp312-cp312-win_amd64.whl (812.6 kB view details)

Uploaded CPython 3.12Windows x86-64

colss-0.1.11-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.11-cp312-cp312-macosx_15_0_arm64.whl (965.5 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

colss-0.1.11-cp311-cp311-win_amd64.whl (810.5 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

colss-0.1.11-cp310-cp310-win_amd64.whl (809.9 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

colss-0.1.11-cp39-cp39-win_amd64.whl (811.0 kB view details)

Uploaded CPython 3.9Windows x86-64

colss-0.1.11-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.11-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.11-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: colss-0.1.11-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 812.6 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.11-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 3c29b7caeb233fc8dda37d495f158cea689bcf04363ee74f67d6f1861b9d60c4
MD5 68d35b799d054e7cac41533a473cda75
BLAKE2b-256 e9f8462d393a2bcfb52a4016989fed91ad3d96c10a739a3c65409e6c9aaec51c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 de54a883e474d4915cebce4aebe9464eb74f46b1b4c9e69866e17d68da6abf74
MD5 f2af835e27361d267bfd2709f1541105
BLAKE2b-256 7eaee0b33cba68a0728f3983ed3c26ed9895303885872b5817a7a0a0bdd9be33

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6db5f5031f0020d2271806246a0c8ca1a641df3ae7c39a4200a15b2707f0c48f
MD5 205eaa6bfb30977a3643a0df9d8db3eb
BLAKE2b-256 c885e60b702ec847b0b0c16221a56f4940beb0dce576c59a2a59eaaf363d3925

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.11-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 812.6 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.11-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1be697ec4b332cf7b30d69c988e75bfb000261c648778dab4cf6ac3df13b09cc
MD5 f87691350d7162976326688b5f65b5f6
BLAKE2b-256 ad9577cc55291509ebbf468b510919f212fa718d651cd494268a0511c3f8d185

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6b135c6e63291219cce887a4a92a6857cf2aaf0eb35eb1b2506e7f143e717871
MD5 e28974188877f46adb5a94e4a0fe9e57
BLAKE2b-256 1a716f405a806eafcdc9863431a09ebebf943738f9945f0a3c662a2162723db2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ca897f7ffa885531d0be24bb4af7c19a051fbfbfc34baec62e3dcb80202a70af
MD5 e3d1fe0ac3241fd5770a60cfe241df65
BLAKE2b-256 1b4caf4353a943b7d68998bd6ede395a833dab2bb22eec335362ff418dfe5abb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.11-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 810.5 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.11-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a1108bb6adc61de2f00bb5e9b2b94de48d68eee9931ceeaca56c4d3221bf9007
MD5 82b1fd82c1b86ce650fcd99ecc28e727
BLAKE2b-256 a7f7811380e2bcfd201d2716849da617783f8b1e005fba492fbbdea28d4d9655

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 09da16e670501f28eeaf3f874c15d70521e98328877325eb5ef06e5a045cf2be
MD5 408fd8cbb4854184fb8a04f5af4a7ce9
BLAKE2b-256 b10f68ff16f8135045a38e409236aa6434f9903e077a468a4f5b9dab22e94536

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 cbb0e4f60b55a08e89878afe5a9923b7e0ce71539ed4f2bdd8b37cff4ce5a998
MD5 83832e4c9f5eb437af8877c106db5096
BLAKE2b-256 03a2dbcc7c1c1d5435f2582c1f09b8e5378948cf199f1b035fecae66752bd780

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.11-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 809.9 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.11-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 3df98c0764128d15edd5e2e0d39552977fff6af0917816b587c24f8322f960ea
MD5 66293af9d521dcf17eb1313412e3c3b5
BLAKE2b-256 e2cb98e76308e414489c6cd719becf6ca334c7d2869e8ad14f0a36674c69bf32

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5376ac76cee3181f698ce6f34b9d369fa0b7bd851e623fd164a8decc101a044d
MD5 646945957aa8b58f86286c5c6b29a560
BLAKE2b-256 c208abb32f556a90db480b299640105282f1f144b959b1ca8af798d39ed6fb1e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1bde2d71e43c8aaa06aedbded52cef410cc023fab450e885c3e23e9a257b8d2f
MD5 a9f7236ada6e3ea41e40c5b3bc8d1465
BLAKE2b-256 621916525f69491b9638c8e28f92d1c76bfec20e94f40bfbb9e7aaea8158a8e5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.11-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 811.0 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.11-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 151260c8f3dcdf7be6a0055b4d4b2879ba8b8c9306c935b2fcffadb6111f2ef5
MD5 a5f35c2086c38670384e12df4289af94
BLAKE2b-256 12e5f63a3dd4f3ef1dd0f2af6886f659b5922d9d52b9db98b2b003e26dae6bbb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7bc718966ce95bd8ad957d872bfaa973c31a1bb5798dc80a0836b43596fbfaff
MD5 cd3978d1ebe7e43740af05e2711d90ff
BLAKE2b-256 0bf9253aaeb44d040163c6ce6dc481f141bba1ea5e8ae7aa31ff2e156368f3ba

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.11-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 f30c85dacfbd1db4a88c99e9ec20ce05890fd30daafd34d9fdc40c5c408cecf9
MD5 10101af32f9aab3c8d3a8a3057f83ef7
BLAKE2b-256 bb6d15ca8a31c39e65026a4a7b90133ba8c8cc6ca3c92a1003f1f3b9e49379a3

See more details on using hashes here.

Provenance

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