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

Source: https://github.com/SivaPA08/colss

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.var("a")
colss.var("a + b")
colss.var("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
import numpy as np
import colss

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

# comparison
colss.query("a > 2")
colss.query("a <= b")
colss.query("a == b")

# logical
colss.query("(a > 1) and (b < 4)")
colss.query("(a > 2) or (b == 1)")
colss.query("not(a > 2)")

# ternary
colss.query("a > 2 ? a * 10 : a + 1")

# conditional
colss.query("if(a>b,a,b)")

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

Uploaded CPython 3.13Windows x86-64

colss-0.2.1-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.1-cp313-cp313-macosx_15_0_arm64.whl (966.3 kB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

colss-0.2.1-cp312-cp312-win_amd64.whl (813.4 kB view details)

Uploaded CPython 3.12Windows x86-64

colss-0.2.1-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.1-cp312-cp312-macosx_15_0_arm64.whl (966.2 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

colss-0.2.1-cp311-cp311-win_amd64.whl (811.0 kB view details)

Uploaded CPython 3.11Windows x86-64

colss-0.2.1-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.1-cp311-cp311-macosx_15_0_arm64.whl (964.9 kB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

colss-0.2.1-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.1-cp310-cp310-macosx_15_0_arm64.whl (963.9 kB view details)

Uploaded CPython 3.10macOS 15.0+ ARM64

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

Uploaded CPython 3.9Windows x86-64

colss-0.2.1-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.1-cp39-cp39-macosx_15_0_arm64.whl (964.1 kB view details)

Uploaded CPython 3.9macOS 15.0+ ARM64

File details

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

File metadata

  • Download URL: colss-0.2.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 812.7 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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 a0b340468c480e0a1f43f25caf45c6367f488f89737f6f84ed27804f203614cd
MD5 369d6bb2e622e0a96d3cc52c8a83a6e2
BLAKE2b-256 17ef04cfd42fcdad70641ed4468f07fb7f3904553289bfc9e0c6912817303e30

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a4dfb433789a0f863443c41669e4e9364290c896205a0666bfb7a61f4e9c6b9e
MD5 9ac9c14feb2c685e5a2201530a6cfa23
BLAKE2b-256 2dfcd7ffdc6b8ca1383970cdfb13850ff8bbfbda6e04c041ecf6d2464c678d7b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b50284f07824469764367fdfc408113ebe61d27ce335ba7d0be19d58ac893811
MD5 00224add049a83a7570c7537925361c5
BLAKE2b-256 3dbeacf7a65f60f3d17a5853119822c1f4311270228326af1c9b1ffc0fe67582

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.2.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 813.4 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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4dd6541a50bc7c38dde8e0ad78b78f6c8018c0e8fc59b56307b6affd3c65b4b3
MD5 1fa7a1d23de792095c4f91ba0a618744
BLAKE2b-256 a08384987c1812df6fa426150e274654a412f522d60c7e23113824135cddc58a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7261291a93a9ae1c28f2530b4eb97ff919a8a7bbdf679145d0a91115b250a78e
MD5 229dcae407ca3bc59b80a6cc89aef33b
BLAKE2b-256 65b0623db8d3a8521fbbcbb7c66c600f9458a62dacfdec5c05ee30f3e117b391

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 ef6bdfd9b49b776185eb6c83d8e31a33b5144e002da30e59a86d73053f716c43
MD5 e1e4efbd1c554172dc667d6c64919af1
BLAKE2b-256 62194872fca1e1c3ae4cc342cd854162e114af2ce6b192050d04e394a3813761

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.2.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 811.0 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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8fabbc995c0ca3989bc744d8dcdeb67073f6629ec5ff9fd7dac0ae13cb19a438
MD5 7bb34a2c7552e5fe4d9537b6125e0de1
BLAKE2b-256 11dc8f649a6f3dae0ef895a1574726f67147e48d9975f809bfec3e61eedc9f61

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 91f45ce85bfdbaa500a11a2df1ac53309c6e535952792146493aa368765d6acc
MD5 42ac8f1d39f043823c3260019e1094c8
BLAKE2b-256 9c858ac51eeb5eb01655af0fd1af2db2fb0326d5abfa20669718c5b3176ccf67

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2c8e77ea798bf141e8337a7595760ab8b90d0ed90f9b6b4ef6c244cf9cec63b0
MD5 bf9938f4d4fad26ca9e539fa1f9d1b83
BLAKE2b-256 ac096b1319df4a189f7fe449ab891702bfc8b96c0f2df831110cd484e93e69d7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.2.1-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.12

File hashes

Hashes for colss-0.2.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 cb05b37ad10542403fc241ac664dd7facfced03335e4c05eaa7f08e321e9f9dd
MD5 cb7dbb6f6cca3404a3a1d04ab7abe9e5
BLAKE2b-256 92fe93b9a8a5e3031a59317044632544ce07df019a3891401b8efed84bb57d5d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ad633454954347b740db21fa8e7a64c190ffc22e69a92f549865b9334630b728
MD5 5624341eae8c5124e90b2c52c4cc86ec
BLAKE2b-256 d279a154a7c5c279de98deca3e190731c43e270da13e02f221dc8568dd4fd02e

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp310-cp310-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 d971aa2894b4b958ca753691157be7ba79c7fa9675dbab94fd771019bf7d0895
MD5 9b8e364d1f7891f926d70e39e0a39541
BLAKE2b-256 3af1b5c42a5a1bb038ec6219fd4885e5b7149024d8524b55878a9c7787466892

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.2.1-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.12

File hashes

Hashes for colss-0.2.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4cef9614506082f91b89585b7a735b4801b7c745d16338dc72367e02702bf115
MD5 4392b91f9104b09e11af98d3b9b17fb7
BLAKE2b-256 762e580cf29b0fac7be049de6a8028dfdce79d3498c073c15cc6cc6523e0afce

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for colss-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f1fa1f168e51101cd6c7c78f94a7af06fe15306843ab3e0f4a98a3a08d3354b6
MD5 5c3f1da5c14722bcd1751709e956ca28
BLAKE2b-256 55c0fc7f4c4bf0b224def3e02ac92be2bbd159c3b7e8e2a8f103a5a3e623d402

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: colss-0.2.1-cp39-cp39-macosx_15_0_arm64.whl
  • Upload date:
  • Size: 964.1 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.1-cp39-cp39-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 fe9bbc72804f083fad5768c968ddfc429ddc2c5de3f4aa18af2726e8f6f69b19
MD5 87c7106e4329efa3742509bf9aca5cc6
BLAKE2b-256 8ecff897762851c9420cd9b32d872dcc475ddc4c3a3d1b4de9ff6c86bcde2d6d

See more details on using hashes here.

Provenance

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