missing
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| DropMissing datacook.engine.ops.missing |
||
| DropMissingColumns datacook.engine.ops.missing |
||
| FillBackward datacook.engine.ops.missing |
||
| FillForward datacook.engine.ops.missing |
||
| FillMissing datacook.engine.ops.missing |
||
| FillWithStatistic datacook.engine.ops.missing `df.fillna(df[cols].mean())` (one fill value per column). |
||
| FilterMissing datacook.engine.ops.missing |
||
| Interpolate datacook.engine.ops.missing |
||
| IsMissing datacook.engine.ops.missing |
||
| NanToMissing datacook.engine.ops.missing `df.mask(lambda d: d !\= d)`: NaN is the only value not equal to itself. |
🛈 DocStrings¶
Missing value ops.
Missing values (policy). Tables use arrow-backed dtypes, where a missing value is a
null (pd.NA): readers produce nulls, isna() / fillna() / dropna() and every op
here work on nulls. A float NaN ("not a number", e.g. from a numpy computation or a
Parquet file written that way) is a value in an arrow float column, not a missing one:
"NaN to missing" turns NaNs into nulls. In numpy float columns (after a cast to "float64")
pandas treats NaN as missing, so the ops behave the same there. Ops that write missing
values write pd.NA, which keeps the column dtype (None would make it object).
FillWithStatistic
¶
Bases: Op
df.fillna(df[cols].mean()) (one fill value per column).
The mode is df[cols].mode().head(1).squeeze(axis=0): the first mode per column, and
no error on an empty table (.iloc[0] would raise).
Source code in src/datacook/engine/ops/missing.py
NanToMissing
¶
Bases: Op
df.mask(lambda d: d != d): NaN is the only value not equal to itself.
Nulls compare as null (not True), so they stay; non-float columns are unchanged.