Skip to main content

A polars expression plugin for splines

Project description

Polars splines

An simple extension plugin for py-polars, that interfaces with the Rust cargo splines, for spline interpolation.

Usage

The expression plugin adds splines to the expression namespace. This contains the method spline which acts on a Series of Struct type. The two fields corresponds to the (x, y) pairs to be interpolated. The spline method accepts a keyword argument xi for the interpolation points.

For example,

import polars as pl
import polars_splines
import numpy as np

x = pl.Series("x", np.linspace(0, 1, 100))
y = pl.Series("y", np.sin(x))

df = pl.DataFrame({"x": x, "y": y})

xi = pl.Series("xi", np.linspace(0, 1, 1000))

dfi = df.select(
    pl.struct("x", "y").splines.spline(list(xi), fill_value=0.0).alias("yi")
).with_columns(xi)

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

polars_splines-0.1.1.tar.gz (13.6 kB view hashes)

Uploaded Source

Built Distribution

polars_splines-0.1.1-cp312-cp312-macosx_11_0_arm64.whl (1.8 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page