Name of the datetime column used to order observations prior to building the spline basis.
required
value_column
str
Name of the numeric column to transform into spline basis features.
required
spline_type
str
Spline family. Supported values are โbsโ (B-spline), โnaturalโ/โcrโ (natural cubic spline) and โcyclicโ/โccโ (cyclic spline). Defaults to โbsโ.
'bs'
df
int
Degrees of freedom passed to the spline constructor. Required unless knots are supplied. Defaults to 5.
5
degree
int
Degree of the polynomial pieces (B-spline only). Defaults to 3.
3
knots
Sequence[float]
Internal knot positions to use when constructing the spline basis.
None
include_intercept
bool
Whether to include the intercept column (B-spline only). Defaults to False.
False
lower_bound
float
Lower boundary for the spline. When omitted the minimum value of value_column is used.
None
upper_bound
float
Upper boundary for the spline. When omitted the maximum value of value_column is used.
None
prefix
str
Custom prefix for the generated column names. When omitted a name is derived from value_column and spline_type.
None
reduce_memory
bool
If True, attempt to downcast numeric columns to reduce memory usage.
False
engine
(auto, pandas, polars)
Execution engine. When set to โautoโ (default) the backend is inferred from the input data type. Use โpandasโ or โpolarsโ to force a specific backend regardless of input type.
"auto"
Returns
Name
Type
Description
DataFrame
DataFrame with spline basis columns appended. The result matches the input data backend (pandas or polars).
Examples
# Pandas Exampleimport pandas as pdimport polars as plimport pytimetk as tkdf = tk.load_dataset('m4_daily', parse_dates=['date'])df_spline = ( df .query("id == 'D10'") .augment_spline( date_column='date', value_column='value', spline_type='bs', df=5, degree=3, prefix='value_bs' ))df_spline.head()