vDataFrame[].str_replace

In [ ]:
vDataFrame[].str_replace(to_replace: str, 
                         value: str = "")

Replaces the regular expression matches in each of the vcolumn record by an input value. The vcolumn will be transformed.

Parameters

Name Type Optional Description
to_replace
str
❌
regular expression to replace.
value
str
✓
new value.

Returns

vDataFrame : self.parent

Example

In [86]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic["name"])
Abc
Varchar(164)
1
2
3
4
5
6
7
8
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
Rows: 1-100 of 1234 | Column: name | Type: varchar(164)
In [87]:
titanic["name"].str_replace(to_replace = " ([A-Za-z])+\.", 
                            value = "VERTICAPY")
Abc
Varchar(2184)
1
2
3
4
5
6
7
8
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
Out[87]:
Rows: 1-100 of 1234 | Column: name | Type: varchar(2184)

See Also

vDataFrame[].str_contains Verifies if the regular expression is in each of the vcolumn records.
vDataFrame[].str_count Computes the regular expression count match in each record of the vcolumn.
vDataFrame[].str_extract Extracts the regular expression in each record of the vcolumn.
vDataFrame[].str_slice Slices the vcolumn.