vastorbit.sql.functions.regexp_like¶
- vastorbit.sql.functions.regexp_like(expr: Annotated[str | list[str] | StringSQL | list[StringSQL], ''], pattern: Annotated[str | list[str] | StringSQL | list[StringSQL], '']) StringSQL¶
Returns true if the string matches the regular expression.
- Parameters:
expr (SQLExpression) – Expression.
pattern (SQLExpression) – A string containing the regular expression to match against the string.
- Returns:
SQL string.
- Return type:
StringSQL
Examples
For this example, we will use the Titanic dataset.
from vastorbit.datasets import load_titanic titanic = load_titanic()
Note
vastorbit offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the vastorbit environment.
Now, let’s import the vastorbit SQL functions.
import vastorbit.sql.functions as vof
Now, let’s go ahead and apply the function.
titanic["has_title"] = vof.regexp_like( titanic["name"], r'([A-Za-z])+\.', ) display(titanic[["name", "has_title"]])
AbcnameVarchar(164)0|1has_titleBoolean1 McCormack, Mr. Thomas Joseph ✓ 2 McCoy, Miss. Agnes ✓ 3 McCoy, Miss. Alicia ✓ 4 McCoy, Mr. Bernard ✓ 5 McDermott, Miss. Brigdet Delia ✓ Note
It’s crucial to utilize vastorbit SQL functions in coding, as they can be updated over time with new syntax. While SQL functions typically remain stable, they may vary across platforms or versions. vastorbit effectively manages these changes, a task not achievable with pure SQL.
See also
VastFrame.eval(): Evaluates the expression.