vDataFrame.regexp¶
In [ ]:
vDataFrame.regexp(column: str,
pattern: str,
method: str = "substr",
position: int = 1,
occurrence: int = 1,
replacement: str = '',
return_position : int = 0,
name: str = "")
Computes a new vcolumn based on regular expressions.
Parameters¶
| Name | Type | Optional | Description |
|---|---|---|---|
column | str | ❌ | Input vcolumn to use to compute the regular expression. |
pattern | str | ❌ | The regular expression. |
method | str | ✓ | Method to use to compute the regular expressions.
|
position | int | ✓ | The number of characters from the start of the string where the function should start searching for matches. |
occurrence | int | ✓ | Controls which occurrence of a pattern match in the string to return. |
replacement | str | ✓ | The string to replace matched substrings. |
return_position | int | ✓ | Sets the position within the string to return. |
name | str | ✓ | New feature name. If empty, a name will be generated. |
In [51]:
from verticapy import *
filmtv_movies = vDataFrame("filmtv_movies")
display(filmtv_movies)
In [52]:
# Retrieving the second actor
filmtv_movies.regexp(column = "actors",
pattern = "[^,]+",
method = "substr",
occurrence = 2,
name = "actor2").select(["actors",
"actor2"])
Out[52]:
In [53]:
# Computing the Number of actors
filmtv_movies.regexp(column = "actors",
pattern = ",",
method = "count",
name = "nb_actors")
filmtv_movies["nb_actors"].add(1)
filmtv_movies.select(["actors", "nb_actors"])
Out[53]:
See Also¶
| vDataFrame.eval | Evaluates a customized expression. |
