dataprep/prep
Types
Values
pub fn collapse_space() -> fn(String) -> String
Collapse consecutive whitespace into a single space.
Uses let assert for the regex compilation. The pattern \s+ is
a fixed, known-valid regular expression, so compilation cannot fail
at runtime. The assert is intentional and safe.
pub fn default(fallback: String) -> fn(String) -> String
Replace the value with fallback when the input is exactly “”.
Note: this checks the literal empty string only. Whitespace-only inputs like “ “ are NOT treated as empty. If you want whitespace-only values to trigger the default, compose with trim:
prep.trim() |> prep.then(first: _, next: prep.default(“N/A”))
pub fn replace(
target target: String,
replacement replacement: String,
) -> fn(String) -> String
Replace all occurrences of target with replacement.
pub fn sequence(steps: List(fn(a) -> a)) -> fn(a) -> a
Compose a list of preps into a single prep. Empty list returns identity.
pub fn then(
first p1: fn(a) -> a,
next p2: fn(a) -> a,
) -> fn(a) -> a
Sequential composition: apply p1, then apply p2 to the result.