API Reference¶
Ingredients
¶
Wrapper around either polars.DataFrame to store columns roles (e.g., predictor) Due to the workings of polars, we do not subclass pl.dataframe anymore, but instead store the dataframe as an attribute. Args: roles: roles of DataFrame columns as (list of) strings. Defaults to None. check_roles: If set to false, doesn't check whether the roles match existing columns. Defaults to True.
See also: pandas.DataFrame
Attributes:
| Name | Type | Description |
|---|---|---|
roles |
dict
|
dictionary of column roles |
Source code in recipies/ingredients.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 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 | |
add_role(column, new_role)
¶
Adds an additional role for a column that already has roles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column to receive additional roles. |
required |
new_role
|
str
|
The role to add to the column. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the column has no role yet. |
Source code in recipies/ingredients.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | |
get_str_dtypes()
¶
" Helper function for polar dataframes to return schema with dtypes as strings
Source code in recipies/ingredients.py
194 195 196 197 198 199 | |
to_df(output_format=None)
¶
Return the underlying DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
Self as DataFrame. |
Source code in recipies/ingredients.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
update_role(column, new_role, old_role=None)
¶
Adds a new role for a column without roles or changes an existing role to a different one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
column
|
str
|
The column to update the roles of. |
required |
new_role
|
str
|
The role to add or change to. |
required |
old_role
|
str
|
Defaults to None. The role to be changed. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If old_role is given but column has no roles. If old_role is given but column has no role old_role. If no old_role is given but column has multiple roles already. |
Source code in recipies/ingredients.py
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 | |
Recipe
¶
Recipe for preprocessing data
A Recipe object combines a pandas-like Ingredients object with one or more sklearn-inspired transformation Steps to turn into a model-ready input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Ingredients | DataFrame | DataFrame
|
data to be preprocessed. |
required |
outcomes
|
Union[str, list[str]]
|
names of columns in data that are assigned the 'outcome' role |
None
|
predictors
|
Union[str, list[str]]
|
names of columns in data that should be assigned the 'predictor' role |
None
|
groups
|
Union[str, list[str]]
|
names of columns in data that should be assigned the 'group' role |
None
|
sequences
|
Union[str, list[str]]
|
names of columns in data that should be assigned the 'sequence' role |
None
|
Source code in recipies/recipe.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 202 203 204 205 206 | |
add_roles(vars, new_role='predictor')
¶
Adds an additional role for one or more columns of the Recipe's Ingredients.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vars
|
Union[str, list[str]]
|
The column to receive additional roles. |
required |
new_role
|
str
|
Defaults to predictor. The role to add to the column. |
'predictor'
|
See also
Ingredients.add_role()
Returns:
| Type | Description |
|---|---|
Recipe
|
self |
Source code in recipies/recipe.py
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
add_step(step)
¶
Adds a new step to the Recipe
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
Step
|
a transformation step that should be applied to the Ingredients during prep() and bake() |
required |
Returns:
| Type | Description |
|---|---|
Recipe
|
self |
Source code in recipies/recipe.py
102 103 104 105 106 107 108 109 110 111 112 | |
bake(data=None)
¶
Transforms, or bakes, the data if it has been prepped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[DataFrame | DataFrame, Ingredients]
|
Data to transform. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame | DataFrame
|
Transformed data. |
Source code in recipies/recipe.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 | |
cache()
¶
Prepares the recipe for caching
Source code in recipies/recipe.py
202 203 204 205 206 | |
prep(data=None, refit=False)
¶
Fits and transforms, in other words preps, the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Union[DataFrame | DataFrame, Ingredients]
|
Data to fit and transform. Defaults to None. |
None
|
refit
|
bool
|
Defaults to False. Whether to refit data. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame | DataFrame
|
Transformed data. |
Source code in recipies/recipe.py
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | |
update_roles(vars, new_role='predictor', old_role=None)
¶
Adds a new role for one or more columns of the Recipe's Ingredients without roles or changes an existing role to a different one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vars
|
Union[str, list[str]]
|
The column to receive additional roles. |
required |
new_role
|
str
|
Defaults to predictor'. The role to add or change to. |
'predictor'
|
old_role
|
str
|
Defaults to None. The role to be changed. |
None
|
See also
Ingredients.update_role()
Returns:
| Type | Description |
|---|---|
Recipe
|
self |
Source code in recipies/recipe.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
Step
¶
This class represents a step in a recipe.
Steps are transformations to be executed on selected columns of a DataFrame. They fit a transformer to the selected columns and afterwards transform the data with the fitted transformer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sel
|
Selector
|
Object that holds information about the selected columns. |
all_predictors()
|
Attributes:
| Name | Type | Description |
|---|---|---|
columns |
List with the names of the selected columns. |
Source code in recipies/step.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 | |
fit(data)
¶
This function fits the transformer to the data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Ingredients
|
The DataFrame to fit to. |
required |
Source code in recipies/step.py
57 58 59 60 61 62 63 64 65 66 | |
transform(data)
¶
This function transforms the data with the fitted transformer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Ingredients
|
The DataFrame to transform. |
required |
Returns:
| Type | Description |
|---|---|
Ingredients
|
The transformed DataFrame. |
Source code in recipies/step.py
94 95 96 97 98 99 100 101 102 103 | |
StepFunction
¶
Bases: Step
Provides a wrapper for a simple transformation function, without fitting.
Source code in recipies/step.py
652 653 654 655 656 657 658 659 660 661 662 663 664 665 | |
StepHistorical
¶
Bases: Step
This step generates columns with a historical accumulator provided by the user.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fun
|
Accumulator
|
Instance of the Accumulator enumerable that signifies which type of historical accumulation to use (default is MAX). |
MAX
|
suffix
|
str
|
Defaults to none. Set the name to have the step generate new columns with this suffix instead of the default suffix. |
None
|
role
|
str
|
Defaults to 'predictor'. In case new columns are added, set their role to role. |
'predictor'
|
Source code in recipies/step.py
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 353 354 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 | |
transform(data)
¶
Raises:
| Type | Description |
|---|---|
TypeError
|
If the function is not of type Accumulator |
Source code in recipies/step.py
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 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 | |
StepImputeFastForwardFill
¶
Bases: Step
Quick variant of pandas' internal nafill(method='ffill') for grouped dataframes.
Note: this variant does not allow for setting a limit.
Source code in recipies/step.py
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 | |
StepImputeFastZeroFill
¶
Bases: Step
Quick variant of pandas' internal nafill(value=0) for grouped dataframes.
Source code in recipies/step.py
189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
StepImputeFill
¶
Bases: Step
For Pandas: uses pandas' internal nafill function to replace missing values.
See pandas.DataFrame.nafill for a description of the arguments.
Source code in recipies/step.py
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 | |
StepImputeModel
¶
Bases: Step
Uses a pretrained imputation model to impute missing values. Args: model: A function that takes a dataframe and the grouping columns as input and returns a dataframe with imputed values without the grouping column.
Source code in recipies/step.py
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | |
StepResampling
¶
Bases: Step
Source code in recipies/step.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 | |
__init__(new_resolution='1h', accumulator_dict=None, default_accumulator=Accumulator.LAST)
¶
This class represents a resampling step in a recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_resolution
|
str
|
Resolution to resample to. |
'1h'
|
accumulator_dict
|
Dict[Selector, Accumulator]
|
Supply dictionary with individual accumulation methods for each Selector. |
None
|
default_accumulator
|
Accumulator
|
Accumulator to use for variables not supplied in dictionary. |
LAST
|
Source code in recipies/step.py
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
StepScale
¶
Bases: StepSklearn
Provides a wrapper for a scaling with StepSklearn. Note that because SKlearn transforms None (nulls) to NaN, we have to revert.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
with_mean
|
bool
|
Defaults to True. If True, center the data before scaling. |
True
|
with_std
|
bool
|
Defaults to True. If True, scale the data to unit variance (or equivalently, unit standard deviation). |
True
|
in_place
|
bool
|
Defaults to True. Set to False to have the step generate new columns instead of overwriting the existing ones. |
True
|
Source code in recipies/step.py
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 | |
StepSklearn
¶
Bases: Step
This step takes a transformer from scikit-learn and makes it usable as a step in a recipe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sklearn_transformer
|
object
|
Instance of scikit-learn transformer that implements fit() and transform(). |
required |
columnwise
|
bool
|
Defaults to False. Set to True to fit and transform the DF column by column. |
False
|
in_place
|
bool
|
Defaults to True. Set to False to have the step generate new columns instead of overwriting the existing ones. |
True
|
role
|
str
|
Defaults to 'predictor'. In case new columns are added, set their role to role. |
'predictor'
|
Source code in recipies/step.py
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 451 452 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 | |
do_fit(data)
¶
Raises:
| Type | Description |
|---|---|
ValueError
|
If the transformer expects a single column but gets multiple. |
Source code in recipies/step.py
426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | |
transform(data)
¶
Raises:
| Type | Description |
|---|---|
TypeError
|
If the transformer returns a sparse matrix. |
ValueError
|
If the transformer returns an unexpected amount of columns. |
Source code in recipies/step.py
448 449 450 451 452 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 | |
Selector
¶
Class responsible for selecting the variables affected by a recipe step. This class is an iterable
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description
|
str
|
Text used to represent Selector when printed in summaries |
required |
names
|
Union[str, list[str]]
|
Column names to select. Defaults to None. |
None
|
roles
|
Union[str, list[str]]
|
Column roles to select, see also Ingredients. Defaults to None. |
None
|
types
|
Union[str, list[str]]
|
Column data types to select. Defaults to None. |
None
|
pattern
|
Pattern
|
Regex pattern to search column names with. Defaults to None. |
None
|
Source code in recipies/selector.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 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 | |
__call__(ingr)
¶
Select variables from Ingredients
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ingr
|
Ingredients
|
object from which to select the variables |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
when something other than an Ingredient object is passed |
Returns:
| Type | Description |
|---|---|
list[str]
|
Selected variables. |
Source code in recipies/selector.py
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 | |
__getitem__(idx)
¶
Allow indexing into the selected columns after being called.
Source code in recipies/selector.py
47 48 49 50 51 | |
__iter__()
¶
Allow Selector to be used as an iterable after being called with Ingredients.
Source code in recipies/selector.py
35 36 37 38 39 | |
__len__()
¶
Return the number of selected columns after being called.
Source code in recipies/selector.py
41 42 43 44 45 | |
set_names(names)
¶
Set the column names to select with this Selector
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Union[str, list[str]]
|
column names to select |
required |
Source code in recipies/selector.py
53 54 55 56 57 58 59 | |
set_pattern(pattern)
¶
Set the pattern to search with this Selector
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pattern
|
Pattern
|
Regex pattern to search column names with. |
required |
Source code in recipies/selector.py
78 79 80 81 82 83 84 | |
set_roles(roles)
¶
Set the column roles to select with this Selector
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles
|
Union[str, list[str]]
|
column roles to select, see also Ingredients |
required |
Source code in recipies/selector.py
61 62 63 64 65 66 67 | |
set_types(roles)
¶
Set the column data types to select with this Selector
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles
|
Union[str, list[str]]
|
column data types to select |
required |
Source code in recipies/selector.py
69 70 71 72 73 74 75 | |
all_groups()
¶
Define selector for all grouping variables
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
334 335 336 337 338 339 340 | |
all_numeric_predictors(backend=Backend.POLARS)
¶
Define selector for all numerical predictor columns
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 | |
all_of(names)
¶
Define selector for any columns with one of the given names
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
Union[str, list[str]]
|
names to select |
required |
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
207 208 209 210 211 212 213 214 215 216 | |
all_outcomes()
¶
Define selector for all outcome columns
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
323 324 325 326 327 328 329 330 331 | |
all_predictors()
¶
Define selector for all predictor columns
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
295 296 297 298 299 300 301 302 303 | |
all_sequences()
¶
Define selector for all grouping variables
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
355 356 357 358 359 360 361 | |
contains(substring)
¶
Define selector for any columns where the name contains the substring
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
substring
|
str
|
substring to search for |
required |
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
256 257 258 259 260 261 262 263 264 265 | |
ends_with(suffix)
¶
Define selector for any columns where the name ends with the suffix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
suffix
|
str
|
suffix to search for |
required |
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
244 245 246 247 248 249 250 251 252 253 | |
enlist_dt(x)
¶
Wrap a pl datatype in a list if it isn't a list yet
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[DataType, list[DataType], None]
|
object to wrap. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If neither a datatype nor a list of datatypes is passed |
Returns:
| Type | Description |
|---|---|
Union[list[DataType], None]
|
description |
Source code in recipies/selector.py
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 | |
enlist_str(x)
¶
Wrap a str in a list if it isn't a list yet
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Union[str, list[str], None]
|
object to wrap. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If neither a str nor a list of strings is passed |
Returns:
| Type | Description |
|---|---|
Union[list[str], None]
|
description |
Source code in recipies/selector.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
has_role(roles)
¶
Define selector for any columns with one of the given roles
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roles
|
Union[str, list[str]]
|
roles to select |
required |
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
268 269 270 271 272 273 274 275 276 277 | |
has_type(types)
¶
Define selector for any columns with one of the given types
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
types
|
Union[str, list[str]]
|
data types to select |
required |
Note
Data types are selected based on string representation as returned by df[[varname]].dtype.name.
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
280 281 282 283 284 285 286 287 288 289 290 291 292 | |
intersection(x, y)
¶
Intersection of two lists
Note
maintains the order of the first list does not deduplicate items (i.e., does not return a set)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
list
|
first list |
required |
y
|
list
|
second list |
required |
Returns:
| Type | Description |
|---|---|
list
|
Elements in |
Source code in recipies/selector.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
regex_names(regex)
¶
Define selector for any columns where the name matches the regex pattern
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
regex
|
str
|
string to be transformed to regex pattern to search for |
required |
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
219 220 221 222 223 224 225 226 227 228 229 | |
select_groups(ingr)
¶
Select any grouping columns
Defines and directly applies Selector(roles=["group"])
Returns:
| Type | Description |
|---|---|
list[str]
|
grouping columns |
Source code in recipies/selector.py
343 344 345 346 347 348 349 350 351 352 | |
select_sequence(ingr)
¶
Select any sequence columns
Defines and directly applies Selector(roles=["sequence"])
Returns:
| Type | Description |
|---|---|
list[str]
|
Grouping columns. |
Source code in recipies/selector.py
364 365 366 367 368 369 370 371 372 | |
starts_with(prefix)
¶
Define selector for any columns where the name starts with the prefix
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prefix
|
str
|
prefix to search for |
required |
Returns:
| Type | Description |
|---|---|
Selector
|
Object representing the selection rule. |
Source code in recipies/selector.py
232 233 234 235 236 237 238 239 240 241 | |