API: preprocessing.cleaning
skyulf.preprocessing.cleaning
Cleaning nodes package.
Importing this package registers all cleaning nodes (text, invalid-value, value, and alias replacement) and re-exports their public classes plus the shared alias-mapping constants for backward compatibility.
AliasReplacementApplier
Bases: BaseApplier
Canonicalise near-duplicate text values in the resolved columns.
The pandas and polars paths must agree value-for-value: each cell is
normalised if it is text (lowercased, punctuation and spaces stripped) and looked up in
the alias map, and a cell that matches nothing is left exactly as it was.
Explicitly selected non-text values are unchanged, including numeric 0/1
and booleans. Cast them to strings first to interpret them as text aliases.
punctuation mode is the exception — it strips punctuation only,
preserving case and spaces.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
apply(X, _y, params)
Dispatch the replacement to the pandas or polars path; y passes through.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
119 120 121 122 123 124 | |
inference_capability(state, *, engine)
staticmethod
Describe existing local row rules without promising engine or dtype parity.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
111 112 113 114 115 116 117 | |
validate_inference_state(raw)
staticmethod
Inspect resolved local alias rules without normalizing their saved values.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
AliasReplacementCalculator
Bases: BaseCalculator
Resolve alias-replacement config into an artifact; nothing is learned from data.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
fit(X, _y, config)
Build the artifact, auto-detecting text columns when none are named.
An explicit empty column selection yields an empty artifact, which
makes the applier a no-op. Legacy alias_type spellings are remapped
and custom_map keys are normalised exactly like runtime values, so
a hand-written map still matches.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
infer_output_schema(input_schema, config)
Pass the input schema through, since only cell values are rewritten.
Source code in skyulf-core/skyulf/preprocessing/cleaning/alias.py
216 217 218 219 220 221 | |
InvalidValueReplacementApplier
Bases: BaseApplier
Replace values violating the configured rule — and optionally ±inf — with a sentinel.
The pandas and polars paths must agree value-for-value: inf/-inf
are replaced first when flagged, then the rule (negative, zero or
custom_range, which honours a single bound when only one is given). A
configuration without an effective rule or an inf flag is skipped outright,
so its values and dtype survive untouched. Active operations require numeric
columns on both engines; text must be explicitly converted before this node.
Infinity-only cleanup preserves integer values and dtypes: integers cannot
contain infinities and must not be widened to a floating-point sentinel.
Active integer rules replacing values with None, NaN or pd.NA use nullable integers,
retaining their width and exact values in full, singleton and empty requests.
Numeric replacements must be exactly representable in the current integer dtype;
fractional or out-of-range replacements require an explicit Casting step first.
Integral floating range bounds are compared as integers to retain exact ordering.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
apply(X, _y, params)
Dispatch the rule to the pandas or polars path; y passes through.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
275 276 277 278 279 280 281 282 | |
inference_capability(state, *, engine)
staticmethod
Describe row dependency while leaving actual schema parity to the probe.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
267 268 269 270 271 272 273 | |
validate_inference_state(raw)
staticmethod
Inspect fixed numeric rules while retaining NumPy sentinels and true no-ops.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
InvalidValueReplacementCalculator
Bases: BaseCalculator
Resolve invalid-value config into an artifact; nothing is learned from data.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
fit(X, _y, config)
Build the artifact, auto-detecting numeric columns when none are named.
An explicit empty column selection yields an empty artifact, which
makes the applier a no-op. UI convenience modes are canonicalised here
rather than in each engine: percentage_bounds/age_bounds become
a custom_range carrying their default bounds unless the user
overrode them, and zero_to_nan becomes zero.
Active rules reject nonnumeric selected columns with ValueError;
the applier repeats this check when inference data changes dtype.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 | |
infer_output_schema(input_schema, config)
Pass the input schema through: sentinels are rewritten in place.
Source code in skyulf-core/skyulf/preprocessing/cleaning/invalid_value.py
367 368 369 370 371 372 | |
TextCleaningApplier
Bases: BaseApplier
Apply an ordered chain of text operations to the resolved columns.
The pandas and polars paths must agree value-for-value. Each column is
coerced to string first, then every entry in operations is applied in
list order so later operations see earlier results. The pandas coercion
masks nulls back afterwards, otherwise astype(str) would turn them into
the literal "nan". Unrecognized operation names raise ValueError, and
an empty column set or empty operation list is a no-op.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | |
apply(X, _y, params)
Dispatch the operation chain to the pandas or polars path; y passes through.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
214 215 216 217 218 219 | |
inference_capability(state, *, engine)
staticmethod
Describe local row operations while retaining engine-specific regex behavior.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
206 207 208 209 210 211 212 | |
validate_inference_state(raw)
staticmethod
Inspect saved operations without rewriting their order, defaults or no-ops.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
TextCleaningCalculator
Bases: BaseCalculator
Resolve text-cleaning config into an artifact; nothing is learned from data.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
fit(X, _y, config)
Build the artifact, auto-detecting text columns when none are named.
Two cases short-circuit to an empty artifact: an explicit
columns: [] from the UI, and auto-detection finding no text columns
at all. Both make the applier a no-op rather than coercing numeric
columns to text.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
infer_output_schema(input_schema, config)
Pass the input schema through: string values are rewritten in place.
Source code in skyulf-core/skyulf/preprocessing/cleaning/text.py
273 274 275 276 277 278 | |
ValueReplacementApplier
Bases: BaseApplier
Replace configured values in the resolved columns, leaving other cells alone.
The pandas and polars paths must agree value-for-value. A mapping wins
over to_replace/value when both are configured, and may be flat
(one map applied to every column) or nested ({column: {old: new}}).
Mapping and to_replace keys are coerced to the column's dtype before
lookup. A list of keys can share one replacement or have a same-length
list of replacements. A column selection resolving to nothing is a no-op.
Numeric rules on integer columns must fit the existing integer dtype; fractional, infinite and out-of-range replacements require an explicit Casting step. Missing replacements use native nullable integers. These checks use configured rules before matching rows, including empty requests. Nonnumeric replacements retain their native engine behavior.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 | |
apply(X, _y, params)
Dispatch the replacement to the pandas or polars path; y passes through.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
416 417 418 419 420 421 | |
inference_capability(state, *, engine)
staticmethod
Describe row dependency without claiming chunk-invariant dtype inference.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
408 409 410 411 412 413 414 | |
validate_inference_state(raw)
staticmethod
Inspect scalar, list, tuple and dictionary state without coercing saved rules.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
398 399 400 401 402 403 404 405 406 | |
ValueReplacementCalculator
Bases: BaseCalculator
Resolve value-replacement config into an artifact; nothing is learned from data.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
fit(X, _y, config)
Build the artifact, folding the UI's replacements pairs into a flat mapping.
A non-empty replacements list overrides any configured mapping.
to_replace/value are carried through untouched for the applier
to fall back on when no mapping survived.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
infer_output_schema(input_schema, config)
Preserve columns and report only output dtypes guaranteed by the active rules.
Integer null rules expose their native nullable type. Data-dependent or unsupported replacements omit the affected dtype; consumers can still validate column references and display the type as unknown.
Source code in skyulf-core/skyulf/preprocessing/cleaning/value_replacement.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 | |