Skip to main content

serif

License: MIT Tests

Python in, Python out. Allowed to raise, not allowed to lie.

Serif is typed vectors and tables for Python, built around two promises: touching your data should feel like ordinary Python, and ambiguous operations should fail loudly.

Values stay Python values — int, float, str, date, None — so there is nothing to convert, unwrap, or remember. And serif does not silently coerce, mutate, or guess. When an operation has no clear meaning, it raises.

Vector provides the foundation. Table is the primary interface for exploration, modeling, and analysis.

30-Second Example

from serif import Table

t = Table({
    "price ($)": [10, 20, 30],
    "quantity":  [4, 5, 6]
})

t >>= {'total': t.price * t.quantity}
t >>= {'tax': t.total * 0.1}

t
# 'price ($)'   quantity   total      tax
#      .price  .quantity  .total     .tax
#       [int]      [int]   [int]  [float]
#          10          4      40      4.0
#          20          5     100     10.0
#          30          6     180     18.0
#
# 3×4 table <int, float>

Installation

pip install serif

Serif has no required runtime dependencies. Its pure-Python implementation defines the semantics; optional accelerators improve performance without changing behavior.

NumPy and PyArrow are used when available, but only when they preserve the same Python values and behavior. Otherwise, Serif falls back to pure Python.

pip install "serif[numpy]"
pip install "serif[pyarrow]"
pip install "serif[numpy,pyarrow]"

Quickstart

Vectors

from serif import Vector

a = Vector([1, 2, 3, 4, 5])

a * 2         # 2, 4, 6, 8, 10
a > 3         # False, False, False, True, True
a[a > 3]      # 4, 5 — boolean masks filter
a.sum()       # 15 — a plain Python int

Tables

from serif import Table

t = Table({
    "first name": ["ann", "bo", "cy"],
    "price ($)":  [10, 20, 30],
})

t.price * 2                    # names sanitize for dot access
t >>= {'total': t.price * 2}   # add a column
t[t.price > 15]                # masks filter rows

t._                            # what do I have again?
# .first_name   str   'first name'
# .price        int   'price ($)'
# .total        int

None means missing

Element-wise, unknown in is unknown out. Aggregates summarize what you know.

v = Vector([10, None, 30])

v + 1        # 11, None, 31
v > 15       # False, None, True
v.sum()      # 40
len(v)       # 3

Joins and aggregation

customers = Table({'id': [1, 2, 3], 'name': ['Ann', 'Bo', 'Cy']})
scores    = Table({'id': [2, 3, 4], 'score': [85, 90, 95]})

customers.inner_join(scores, left_on='id', right_on='id')
# id, name, score — matched key columns are not duplicated

sales = Table({'customer': ['A', 'B', 'A'], 'amount': [100, 200, 150]})

sales.aggregate(
    groupby=sales.customer,
    aggregations={'total': sales.amount.sum, 'n': len},
)
# customer  total      n
# [str]     [int]  [int]
# A           250      2
# B           200      1
#
# 2×3 table <int, str>

CSV and Parquet

from serif import read_csv, read_parquet

t = read_csv("sales.csv")        # types inferred, headers sanitized for dot access
t.to_parquet("sales.parquet")    # ints, dates, and nulls arrive intact
u = read_parquet("sales.parquet")
recent = u[u.date >= cutoff]      # remaining columns load through this mask

read_parquet reads the footer first and materializes columns only when they are touched. Boolean filtering stays ordinary Serif filtering: the concrete mask is carried into columns that have not been read yet, so the first fully materialized table can be the filtered one. Keep the source file readable and unchanged until the table has materialized.

Documentation

License

MIT

Contributing

See CONTRIBUTING.md and CODE_OF_CONDUCT.md.

Metadata

Release files for serif 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for serif 0.2.2
File Size Uploaded Provenance Actions
serif-0.2.2.tar.gz 283.4 kB Without provenance Details for serif-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for serif 0.2.2
File Interpreter ABI Platform Actions
serif-0.2.2-py3-none-any.whl Python 3 none any Details for serif-0.2.2-py3-none-any.whl

Total release size: 443.3 kB

Release files / serif-0.2.2.tar.gz

Download URL serif-0.2.2.tar.gz
Size 283.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fec794011791b74f7551214e572ef7a692947cd5a9cd5568dce38e79cc1d9538
BLAKE2b-256 checksum
How to use checksums
13eda30eb974e4b017ee5a95df38386ee5dc33e825a0a0a31b899283661f60d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / serif-0.2.2-py3-none-any.whl

Download URL serif-0.2.2-py3-none-any.whl
Size 159.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d24479e7b56bb084efee62d9fab4ef722ca666c21ea00d68abbc24ae8ca53b64
BLAKE2b-256 checksum
How to use checksums
7ef550fb3f886f1bf5870b4f637270a0b3bcc532d92aa6485fecb776e0298f49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for serif 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page