Skip to main content

Crate fp_types

Crate fp_types 

Source
Expand description

Foundational value-type abstractions for frankenpandas — the enums, structs, and free functions that every other crate (fp-columnar, fp-index, fp-frame, fp-io, …) consumes when representing scalar data, dtypes, missing values, and time deltas.

The types here intentionally stay tiny and dependency-light (serde, thiserror) so they can sit at the bottom of the workspace dep graph.

§Core value types

  • DType: the dtype enum — Null, Bool, Int64, Float64, Utf8, Categorical, Timedelta64, Datetime64, Period, Interval, Sparse. Drives column / series storage decisions across the workspace.
  • Scalar: the per-cell value enum, parameterized by DType. Each variant holds the actual data (Int64(i64), Float64(f64), Utf8(String), …) plus the Null(NullKind) variant for missing values.
  • NullKind: distinguishes the three pandas missing-value “flavors” — Null (Python None / SQL NULL), NaN (floating-point not-a-number), NaT (timedelta / datetime not-a-time). Scalar::Null(...) carries the kind so downstream code can preserve pandas semantics.
  • SparseDType: descriptor for sparse-encoded dtypes (paired value dtype + fill value).

§Time / duration types

§Dtype inference + casting

§Missing-value helpers

Free fns matching pd.isna / pd.notna, plus fill/drop helpers, plus the nan* aggregations (nansum, nanmean, nancount, nanmin, nanmax, nanmedian, nanvar, nanstd) that mirror pandas’ missing-aware reductions.

⚠️ Only HALF that list is a module-level pandas surface. pd.isna and pd.notna are free functions; pd.fillna and pd.dropna do NOT exist (measured 2.2.3: AttributeError on the module) – pandas exposes fill and drop only as METHODS, Series.fillna / DataFrame.dropna. The free fns here are an FP convenience, not a pandas mirror.

§Error reporting

Errors are explicit enums via thiserror: TypeError for dtype-related failures (incompatible-cast, no-common-dtype) and TimedeltaError for parse failures.

Modules§

overflow_audit
Deterministic, opt-in audit trail for HARDENED-mode recoveries.

Structs§

Interval
A bounded numeric interval between two f64 endpoints.
Period
A single pandas-style Period value.
SparseDType
TemporalFailure
A temporal overflow, naming the operation that overflowed and the pandas exception it corresponds to.
TemporalRecovery
A bounded defensive recovery that HARDENED mode performed, recorded so a run can be audited after the fact.
Timedelta
TimedeltaComponents
Timestamp
A nanosecond-precision point in time, Unix-epoch anchored.

Enums§

DType
DatetimeStringResolution
How wide astype(str) renders a datetime64[ns] value.
IntervalClosed
Endpoint-inclusion policy for an Interval.
NullKind
OverflowPolicy
How a temporal overflow should be surfaced.
PandasTemporalError
The pandas-side exception class a failed temporal operation corresponds to.
PeriodFreq
Period frequency code. Matches pandas offset alias core set.
Scalar
TimedeltaError
TimedeltaStringResolution
How astype(str) renders a timedelta64[ns] COLUMN.
TypeError

Functions§

cast_scalar
Cast a scalar reference to a target dtype (clones only when conversion is needed).
cast_scalar_owned
Cast a scalar to a target dtype, taking ownership to avoid redundant clones when the value already has the correct type (AG-03: identity-cast skip).
common_dtype
count_na
dropna
fill_na
float_to_string_for_astype
infer_dtype
interval_range_by_periods
Build periods equal-width intervals spanning [start, end].
interval_range_by_step
Build equal-step-width intervals spanning [start, end].
isna
isnull
nanall
nanany
nanargmax
Position (in the original slice) of the non-missing maximum.
nanargmin
Position (in the original slice) of the non-missing minimum.
nancount
nancummax
Cumulative maximum respecting null propagation.
nancummin
Cumulative minimum respecting null propagation.
nancumprod
Cumulative product respecting null propagation.
nancumsum
nancumsum_with_policy
Matches np.nancumsum / pd.Series.cumsum(). Missing input positions pass through as Null(NaN) in the output; the running sum ignores those positions when accumulating. Cumulative sum under an explicit overflow policy.
nankurt
Excess sample kurtosis (Fisher’s definition, bias-corrected) over non-missing values.
nanmax
nanmean
nanmedian
nanmin
nannunique
Count of unique non-missing values.
nanprod
Product of non-missing values. Returns 1.0 for empty input (matching pandas).
nanptp
Peak-to-peak range of non-missing values (max − min).
nanquantile
Linear-interpolation quantile over non-missing numeric values.
nansem
Standard error of the mean over non-missing values.
nanskew
Sample skewness (bias-corrected, Fisher-Pearson) over non-missing values.
nanstd
nansum
nansum_utf8
Sum of a STRING group: pandas concatenates, skipping missing entries.
nanvar
notna
notnull
period_range
Build periods consecutive Periods starting at start.