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 byDType. Each variant holds the actual data (Int64(i64),Float64(f64),Utf8(String), …) plus theNull(NullKind)variant for missing values.NullKind: distinguishes the three pandas missing-value “flavors” —Null(PythonNone/ 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
Timedelta: nanosecond-precision duration with arithmetic helpers (Timedelta::add,Timedelta::sub,Timedelta::mul_scalar,Timedelta::div_scalar,Timedelta::div_timedelta) that propagateNaTper pandas semantics.TimedeltaComponentsbreaks a timedelta into days/hours/minutes/seconds/nanos for display.Timestamp: nanosecond-precision wall-clock timestamp with optional timezone. Includes floor / ceil / round helpers andNaTpropagation.
§Dtype inference + casting
infer_dtype: derive aDTypefrom a slice of scalars (used during DataFrame construction).common_dtype: pandas-style dtype promotion for binary ops.cast_scalar/cast_scalar_owned: convert a scalar to a target dtype with explicit error reporting on impossible casts.
§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.
Re-exports§
pub use api::types::pandas_dtype;
Modules§
- api
- Public pandas API modules (
pandas.api.*). - overflow_
audit - Deterministic, opt-in audit trail for HARDENED-mode recoveries.
Structs§
- Categorical
Dtype - Pandas-equivalent categorical dtype descriptor (
pd.CategoricalDtype). - Categorical
Metadata - Host
Value - A shared handle on a
HostObject. - Interval
- A bounded numeric interval between two
f64endpoints. - Interval
Dtype - Pandas-equivalent interval dtype descriptor (
pd.IntervalDtype). - Kahan
Sum - pandas’ compensated running sum: its cython
group_sum,group_meanandgroup_cumsumadd each float asy = v - comp; t = sum + y; comp = t - sum - y; sum = t(Kahan),compreset to 0 where it is NaN (an inf added; GH#53606). A plain+=fold differs from it in the last bits - groupby sum of ten 0.1 is 1.0 in pandas, 0.9999999999999999 naively (br-frankenpandas-xhogl). - Option
Context Guard - RAII scope guard that restores options to their prior values when dropped.
- Pandas
Reductions - pandas’ float reductions of one numeric column -
sum,mean,var,std,sem,skew,kurt- adding in numpy’s exact order, so a long column answers pandas’ bits rather than a nearby value. Measured against live pandas 2.2.3 / numpy 2.3.5; bead br-frankenpandas-9iim6 holds the model and the alternatives it rejected. - Period
- A single pandas-style Period value.
- Period
Dtype - Pandas-equivalent period dtype descriptor (
pd.PeriodDtype). - Skew
Moments - pandas’ online skewness: its cython
group_skewfolds each float into running moments (delta = v - m1; delta_n = delta / n; term1 = delta * delta_n * (n - 1); m1 += delta_n; m3 += term1 * delta_n * (n - 2) - 3 * delta_n * m2; m2 += term1) and answersn * (n - 1) ** 0.5 / (n - 2) * (m3 / m2 ** 1.5)- 0 whenm2is 0, missing below 3 values - where the two-passnanskew(Series.skew) differs in the last bits (br-frankenpandas-vjfq9). - SparseD
Type - Temporal
Failure - A temporal overflow, naming the operation that overflowed and the pandas exception it corresponds to.
- Temporal
Recovery - A bounded defensive recovery that HARDENED mode performed, recorded so a run can be audited after the fact.
- Timedelta
- Timedelta
Components - Timestamp
- A nanosecond-precision point in time, Unix-epoch anchored.
- Welford
Var - pandas’ online variance: its cython
group_varfolds each float as Welford (mean += (v - old) / n; m2 += (v - mean) * (v - old)) and answersm2 / (n - ddof), std its square root and semsqrt(m2 / (n - ddof) / n)- where the two-pass form differs in the last bits (a constant group’s var is 0.0, not 1e-34; br-frankenpandas-xhogl).
Enums§
- Ambiguous
Time - What
tz_localizedoes with a wall time a DST change repeats (pandas’ambiguous=, for one value): refuse it, take its first occurrence (DST, pandas’True) or its second (standard time,False), or make it NaT. - DType
- Datetime
String Resolution - How wide
astype(str)renders adatetime64[ns]value. - Interval
Closed - Endpoint-inclusion policy for an
Interval. - Interval
Subtype - The type of an interval’s endpoints, pandas’
interval[int64]orinterval[float64]subtype: integer endpoints print without ‘.0’ (pd.cut(s, [0, 3, 6])is(0, 3], where float edges are(0.0, 3.0]). The endpoints themselves aref64either way (fvsao.54). - Missing
Layout - How pandas holds a column’s missing values, which decides the order its float reductions add in (br-frankenpandas-9iim6).
- Nonexistent
Time - What
tz_localizedoes with a wall time a DST change skips (pandas’nonexistent=): refuse it, move it to the first instant after the gap (shift_forward) or the last nanosecond before it (shift_backward), make it NaT, or move the wall time by a duration (nanoseconds) and localize that. - Null
Kind - Numeric
Width - A numpy numeric dtype narrower than the 64-bit storage a column keeps its values in: pandas’ int8 / int16 / int32, uint8 / uint16 / uint32 / uint64 and float32, and over a nullable column the masked Int8 … UInt64 / Float32 (fvsao.23).
- Numpy
Numeric - A numeric column’s numpy dtype as numpy’s promotion sees it: kind and
bits. The 64-bit ones are a column without a
NumericWidth. - Object
Value - A pandas object cell that is not one of
Scalar’s value kinds: a list, or a value of the host language (a Pythondatetime.date, dict, numpy dtype) that the core carries without reading (fvsao.33). - Option
Error - Error encountered when inspecting or modifying configuration options.
- Option
Value - Represents a configuration option value, matching pandas
pd.options. - Overflow
Policy - How a temporal overflow should be surfaced.
- Pandas
Decimal - What pandas’ default text-to-float64 conversion -
read_csv/read_tablewithfloat_precision=Noneor'high', andto_numericof strings - makes of a token (br-frankenpandas-py3c0). - Pandas
Temporal Error - The pandas-side exception class a failed temporal operation corresponds to.
- Period
Freq - Period frequency code. Matches pandas offset alias core set.
- Reduction
Values - A numeric column’s values as pandas’ float reductions read them: one
buffer or the chunks of one (a
concatresult), float64 or a numpy int64 array (read through numpy’s int64 -> float64 cast; ints that pandas holds as float64 because one is missing areFloat). - Scalar
- Time
Zone Error - Why a time-zone conversion failed, as pandas (pytz) classifies it.
- Timedelta
Error - Timedelta
String Resolution - How
astype(str)renders atimedelta64[ns]COLUMN. - Type
Error
Constants§
- NA
- Pandas
pd.NAsingleton representing missing data in nullable dtypes. - NAT
- Pandas
pd.NaTsingleton representing Not-a-Time in datetime/timedelta data. - NaT
- Alias for
NATmatching pandas capitalizationpd.NaT.
Traits§
- AsDType
- Trait for types that carry or represent a
DType. - Host
Object - A host-language value an object cell carries - the Python binding’s objects: compared and printed by the host itself.
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 - declare_
host_ lock - Declare that callers into the core may hold a host lock that host objects need - the Python binding, whose every call holds the GIL, declares it when its module loads. Without it no worker is ever blocked.
- describe_
option - Return formatted descriptions of one or all options, matching
pd.describe_option(pat). - dropna
- eng_
float_ format - Format float values according to engineering format, matching pandas
EngFormatter. - fill_na
- float_
to_ string_ for_ astype - get_
eng_ float_ format - Get the current engineering float format configuration if active.
- get_
option - Retrieve the current value of a configuration option, matching
pd.get_option(pat). - host_
values_ block_ workers - Whether a parallel kernel must run inline (one worker): a host value
compares, hashes and prints through its host (Python), which a worker
thread reaches only by taking the host’s lock (the GIL); when the thread
that spawned the worker holds that lock while it waits for the worker,
both wait forever -
DataFrame.groupby(dates).rank()hung that way (4qg5w.13). So while any host object is alive in a process whose callers may hold that lock, kernels size themselves to one worker. - infer_
dtype - interval_
range - Build equal-width intervals spanning a range, matching
pd.interval_range. - interval_
range_ by_ periods - Build
periodsequal-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 asNull(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
- nanmean_
grouped nanmeanas pandas’ grouped mean: theKahanSumover the count. Temporal input keepsnanmean.- 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.
- nansem_
grouped - Standard error of the mean as pandas’ groupby, resample and pivot_table
compute it:
sqrt(var / n)(libgroupby’sgroup_var(name="sem")), which can differ in the last bit fromnansem’sstd / sqrt(n)(Series.sem): for[1.0, 4.0]this is1.5and nansem1.4999999999999998(br-frankenpandas-7hxqv). Timedelta input keepsnansem. - nanskew
- Sample skewness (bias-corrected, Fisher-Pearson) over non-missing values.
- nanskew_
grouped nanskewas pandas’ grouped skew:SkewMomentsover the present values.- nanstd
- nanstd_
grouped nanstdas pandas’ grouped std:WelfordVar. Temporal input keepsnanstd.- nansum
- nansum_
grouped nansumas pandas’ groupby / resample / pivot_table add floats: the compensatedKahanSum(br-frankenpandas-xhogl). Timedelta input keepsnansum’s exact integer sum.- nansum_
utf8 - Sum of a STRING group: pandas concatenates, skipping missing entries.
- nanvar
- nanvar_
grouped nanvaras pandas’ grouped var:WelfordVar. Timedelta input keepsnanvar.- notna
- notnull
- numpy_
pairwise_ sum - numpy’s
pairwise_sum, the kernel of its floatadd.reduceover a contiguous run, every addition inT: below 8 values a running sum from 0; up to 128, eight running sums seeded with the first eight values and stepped over the 8-value blocks, folded as((r0 + r1) + (r2 + r3)) + ((r4 + r5) + (r6 + r7)), then the remainder in order; beyond that the two halves (the first a multiple of 8 long) summed apart. pandas’ float32 and float64 sums are it bit for bit, where a sum rounded once or added left to right differs in the last place (fvsao.23, br-frankenpandas-9iim6). - numpy_
pairwise_ sum_ by numpy_pairwise_sumoverlenvalues that numpy reads from one array but fp holds in another shape (a cast, chunks, missing slots as 0):fill(start, block)writes valuesstart..start + block.len()into each block, at most 128 long, the blocks asked for left to right.- option_
context - Temporarily override options within a scoped context, matching
pd.option_context(...). - pandas_
decimal_ to_ f64 - pandas’ default text-to-float64 conversion of
token(no surrounding space). It is not correctly rounded: the first 17 digits - leading zeros count - accumulate asx * 10 + din float64 (digits past them in the integer part raise the exponent, in the fraction they are dropped), the exponent is a wrapping 32-bit integer of at most 17 digits, and the value is scaled ONCE by a float64 power of ten:x * 1e{e}foreup to 308,x / 1e{-e}down to -308,x / 1e{-308-e} / 1e308down to -616,+0.0below that; past 308, or overflowing to infinity, the token is not a float. The sign applies last. Measured against live pandas 2.2.3 over 180k tokens (repr /%.20e/%.25f/ 1-30 digit fractions / leading zeros / exponents to +-640 / wrapping exponents), 0 mismatches;float()misses about a third of them. - pandas_
int_ to_ f64 - An integer cell of a column pandas reads as float64 (one of its cells is
fractional): the integer’s digits through
pandas_decimal_to_f64, exact up to 2^53. - period_
range - Build
periodsconsecutive Periods starting atstart. - python_
bytes_ repr - Python’s
reprof a bytes value:b'...'(double quotes when it holds a'and no"), printable ASCII as itself,\\,\t,\n,\rand the quote escaped, every other byte as\xNN. - reset_
eng_ float_ format - Reset engineering float formatting back to default.
- reset_
option - Reset one or all configuration options to their defaults, matching
pd.reset_option(pat). - set_
eng_ float_ format - Set pandas-compatible engineering float formatting option.
Matches
pd.set_eng_float_format(accuracy=3, use_eng_prefix=False). - set_
option - Set the value of a configuration option, matching
pd.set_option(pat, value). - spread_
float_ bits - A float key’s bits spread for an FxHash table: the high half folded into the low (bijective, so equal bits stay equal and distinct stay distinct). An integer-valued float’s bits end in up to 52 zeros, which FxHash’s multiply keeps where the table takes its bucket from: 100 round keys shared about two buckets, and drop_duplicates / duplicated / groupby of round floats ran 4-6x slower than of fractional ones. The splitmix64 finalizer spread them too but cost fractional keys a sixth (br-frankenpandas-mixf64, br-frankenpandas-bss5q.3).
- strftime_
in_ zone - The instant
nanosformatted bystrftime_python: a naive value as it is; intz(a tz-aware value,nanosits UTC instant) on the zone’s wall clock with the offset and abbreviation of that instant. - strftime_
python wall_nanosformatted as Python’s (glibc’s)strftimedoes - what pandas’Timestamp.strftime/Series.dt.strftime/to_csv(date_format=)run per value: the C-locale directives (%a %A %b %B %c %d %e %f %H %I %j %m %M %p %S %U %w %W %x %X %y %Y %z %Z %%), glibc’s (%C %D %F %g %G %h %k %l %n %P %r %R %t %T %u %V) and its-(no padding),_(space padding),0and^(upper case) flags. An unknown directive is echoed as written, as glibc does.zoneis a tz-aware value’s UTC offset (in seconds) and abbreviation at that instant, which%z/%Zprint (empty for a naive value).- timestamp_
text str(Timestamp)of the naive instantnanos: its wall clock ‘YYYY-MM-DD HH:MM:SS’ and its own fraction when it has one (six digits, nine for nanoseconds) - how pandas prints a naive Timestamp an object column holds (astype(str)spelled it ‘Timestamp[]’; br-frankenpandas-srzqw). - timestamp_
text_ in_ zone str(Timestamp)of the instantnanosintz, as pandas prints a tz-aware value (repr cells,astype(str)): itstimestamp_textwall clock and the zone’s+HH:MMoffset then.- tz_
abbreviation - The zone’s name at the UTC instant
utc_nanosasstrftime('%Z')prints it: an IANA zone’s abbreviation then (‘EST’ / ‘EDT’), a fixed offset’sUTC+HH:MM(‘UTC’ for zero). - tz_
canonical_ name - The name pandas gives the zone
tz: a fixed offset isUTC+HH:MM(‘+05:30’ and ‘UTC+05:30’ alike; a zero offset or ‘Z’ is ‘UTC’), an IANA name stays as given. - tz_
offset_ seconds - The UTC offset, in seconds east of UTC, that
tzhas at the UTC instantutc_nanos- what a tz-aware timestamp adds to its instant to show its wall clock. - tz_
utc_ to_ wall_ nanos - The wall clock the UTC instant
utc_nanosshows intz, as naive nanoseconds (NaT,i64::MIN, stays NaT). - tz_
validate - Whether
tznames a zone pandas accepts (‘UTC’,+HH:MM, an IANA name). - tz_
wall_ to_ utc_ nanos - The UTC instant of the wall-clock time
wall_nanosintz, as pandas’tz_localizewith ambiguous / nonexistent = ‘raise’: a wall time a DST change skips isTimeZoneError::NonExistent, one it repeatsTimeZoneError::Ambiguous. NaT (i64::MIN) stays NaT. - tz_
wall_ to_ utc_ nanos_ with tz_wall_to_utc_nanosunder pandas’ambiguous/nonexistentpolicies; NaT (i64::MIN) where a policy says NaT.