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

sigma

Returns the sum of the evaluated expression as a scalar.

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 15.0+ ARM64

colss-0.1.10-cp310-cp310-win_amd64.whl (810.0 kB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 15.0+ ARM64

colss-0.1.10-cp39-cp39-win_amd64.whl (810.4 kB view details)

Uploaded CPython 3.9Windows x86-64

colss-0.1.10-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.10-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.10-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: colss-0.1.10-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.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 5f0680cfa2761d7680ef93b0e747f9e4bf45d347891e2f320f049340c138af1c
MD5 119466636b626383678d0edba2134832
BLAKE2b-256 243aa46566e6b757ea52f87166403ce56fc16e8e74d0c63d4b9e396191e4923b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1d5ca2ee1c2583407b71725e6e8fc95e2c884e5d515bd9caab213d8d02842e32
MD5 788dd15456358f1b1d10416fd50d3745
BLAKE2b-256 1bc6681fece749ad5e9a171538ec8b2c7403041401ad83ca7ed246019fa39245

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2695804cbf1468a9568f9b75fa798f2c47f0deb2f8b0f0c185ac5433017c3599
MD5 f456ff2fa4edd6a3164207b6b4be64af
BLAKE2b-256 3710070910b0721ff0f397dd6fdd140bf6fec1014e4dc3792bb04d9b05d1f6b4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.10-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.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2a163c0160d950cd35832d643828e5478544f11805634fd8ff43b45d106b360a
MD5 d1c4438f56f02ea18c3a25f1fb90b30d
BLAKE2b-256 1e6fe7f7675278ccc199b988b3112b6ca5dcfb67570a01c8b7391310473bf884

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe9d13f646f63f39fe7c4b9e9bb5f248b14b74251b387b3797d47ad757c049bc
MD5 2c5898b6482230a34add1d5b806cab67
BLAKE2b-256 0a27cc01bd4fa79802ac5703e4be635ccff233d02af7055090985962a12384a3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c121ad722d8b2b906a798931833481c74e8c71cfd77095de19eb3c7e1c8d9310
MD5 1a3ea0335f22f43e5dff70d3094a15e5
BLAKE2b-256 373510754f38a576a53826ed670a0b6395e1acfdcaf95603f955f54d28c4f626

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.10-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.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 249cbf4be286b2351ece0919b70837558c7effe7c5d3ec3fe3f6bf524cd0e597
MD5 6ebf64b193c191c9e56de48e31ffcd12
BLAKE2b-256 dccd45e2954bf904def214b56cb032ae5b9a7281b87d92b220575f7a018fe476

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 98a6171e831d65f8d8c8c3ccff879e3e187c2644e8e55b31b1122aae26ebdf74
MD5 059fc2ff770f384c5d8d7ae3428bc899
BLAKE2b-256 2696e5f32960006c41ebcd0f14b7c7a00738cae07ed0e34121a1ce6d08069735

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b16996068fce96868a90664dffed696606aa07e2706563b090d7b937c4f788c3
MD5 102dd877a3f25d4437d99358a5867931
BLAKE2b-256 985d6a953eda606fd193c648c117979e3a4f05f1fd72d7ec60f7a8961fde3b7f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.10-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 810.0 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.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 11bd37aa53c80aae90399ae12e55b28d7244d1c64cec67ca4c0ee94cd68c1871
MD5 ee3328e9751c93795ae452eac827f0ef
BLAKE2b-256 624ed09cd4041e3eb073601bf714bd9408dc13acd7e83692735d425823b73479

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f7313979c22b95d83e9ec50924bf5d4a4df1cbabb5235aae1b8083e80953c194
MD5 a96feba7f5c7d01ce2d5eca69cffa2c5
BLAKE2b-256 9b6c461299292887bf000f0737e367284bb8a9a4e5fea533a1b1ccf8d23382f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 208c13458bef5ca4a4d0c49684f733bf12f33f8306a62eece12d37c7bf49342f
MD5 5a60438c56729e63e3f3d3701fa411a6
BLAKE2b-256 ff152a0490c26602ebb7ac20dc0f7a96623230bf7ec90e2f720ea6ad7f46ce99

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.1.10-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 810.4 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.10-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 2a2ecce33648727593e793cfee1f00d309b28bf5ffde81bd5cc5b5bef587588e
MD5 b148c403dd7ff976b5ea87a00e6cfda4
BLAKE2b-256 f9d28561d8e769e4c5fc356162b57e81fb229cff67c575de07bb0e60d8bdd6e6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cc37833536541e1f0ade7e1aa68bd7964621e350a38601ec39a26407797ec5d1
MD5 49030072db79d7dedc9683c420b7652e
BLAKE2b-256 37d1917845badb6cc3325c678fe93a073e05f378c6072c0c0334ab7fb2db0b6b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.1.10-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 1d707c51fc9a7829cce9406916f48e6659b26652fb0c94d8eea823991dd8021f
MD5 f1c1936a6bab5eea58716c901cf098e6
BLAKE2b-256 412b43a9c9315f2b5ce37de44d2b3611c2f8aafdab20f3244221248c9ca830be

See more details on using hashes here.

Provenance

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