Skip to main content

A Python library for working with digital scholarly editions in polars dataframes.

Project description

dse_polars

Work with DSE triples in a polars dataframe

ctsurn_contains usage

ctsurn_contains returns a Polars expression, so you can use it directly in filter/select.

import polars as pl
from dse_polars.texts import ctsurn_contains

df = pl.DataFrame(
	{
		"urn": [
			"urn:cts:compnov:bible.genesis.sept_latin:1.1",
			"urn:cts:compnov:bible.genesis.sept_latin:2.1",
			"urn:cts:compnov:bible.exodus.sept_latin:1.1",
		]
	}
)

query = "urn:cts:compnov:bible.genesis:1"

matches = df.filter(ctsurn_contains(pl.col("urn"), query))
print(matches)

# quick boolean check with literals
is_contained = pl.select(
	ctsurn_contains(
		"urn:cts:compnov:bible.genesis.sept_latin:1.1",
		"urn:cts:compnov:bible.genesis:1",
	).alias("ok")
).item(0, 0)
print(is_contained)  # True

ptinrect usage

ptinrect returns a Polars expression, so you can use it directly in filter/select.

import polars as pl
from dse_polars.images import ptinrect

rects = pl.DataFrame(
	{
		"label": ["A", "B"],
		"x": [10.0, 100.0],
		"y": [20.0, 200.0],
		"w": [30.0, 20.0],
		"h": [40.0, 20.0],
	}
)

# filter rectangles containing a literal point (25, 35)
hits = rects.filter(ptinrect(25.0, 35.0))
print(hits)

# use point columns too
points = pl.DataFrame({"px": [25.0, 130.0], "py": [35.0, 210.0]})
checks = rects.with_columns(points).select(
	pl.col("label"),
	ptinrect(pl.col("px"), pl.col("py")).alias("contains_point"),
)
print(checks)

textcontents usage

textcontents returns a Python list of values in the text column, excluding nulls.

import polars as pl
from dse_polars.texts import textcontents

df = pl.DataFrame(
	{
		"urn": ["u1", "u2", "u3", "u4"],
		"text": ["alpha", None, "beta", "alpha"],
	}
)

contents = textcontents(df)
print(contents)  # ['alpha', 'beta', 'alpha']

Project details


Download files

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

Source Distribution

dse_polars-0.3.1.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

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

dse_polars-0.3.1-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file dse_polars-0.3.1.tar.gz.

File metadata

  • Download URL: dse_polars-0.3.1.tar.gz
  • Upload date:
  • Size: 4.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dse_polars-0.3.1.tar.gz
Algorithm Hash digest
SHA256 e2a78e3646a9e3952947f0718fba52db88a3955ac189bf34ad4f2aaeac6557a9
MD5 e05fb2c1ce51f0aaeecf40b0c75002f7
BLAKE2b-256 9da0ddf133b2bc96b338348c75742a2ebfd997caf23ec2aa3a292e53bc25f9e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for dse_polars-0.3.1.tar.gz:

Publisher: publish.yml on neelsmith/dse_polars

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

File details

Details for the file dse_polars-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dse_polars-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for dse_polars-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e687db5f92b317c8741922ef870a5b129e3c216b746cb101f42783b75dd6126d
MD5 25d0535fc8f813ce05a94192f75c9440
BLAKE2b-256 45de0986899215d208a80a27723a83d0ff9c44be71f1ea025f2fb661b10edcad

See more details on using hashes here.

Provenance

The following attestation bundles were made for dse_polars-0.3.1-py3-none-any.whl:

Publisher: publish.yml on neelsmith/dse_polars

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