vDataFrame[].decode

In [ ]:
vDataFrame[].decode(*argv)

Encodes the vcolumn using a user-defined encoding.

Parameters

Name Type Optional Description
argv
object
Infinite Number of Expressions. The expression generated will look like:
  • even: CASE ... WHEN vcolumn = argv[2 * i] THEN argv[2 * i + 1] ... END
  • odd : CASE ... WHEN vcolumn = argv[2 * i] THEN argv[2 * i + 1] ... ELSE argv[n] END

Returns

vDataFrame : self.parent

Example

In [8]:
from verticapy.datasets import load_titanic
titanic = load_titanic()
display(titanic["sex"])
Abc
sex
Varchar(20)
1female
2male
3female
4male
5male
6male
7male
8male
9male
10male
11male
12male
13male
14male
15male
16male
17male
18male
19male
20male
21male
22male
23male
24male
25male
26male
27male
28male
29male
30male
31male
32male
33male
34male
35female
36male
37male
38male
39male
40male
41male
42male
43male
44male
45male
46male
47male
48male
49male
50male
51male
52male
53male
54male
55male
56male
57female
58male
59male
60male
61male
62male
63male
64male
65male
66male
67male
68male
69male
70male
71male
72male
73male
74male
75male
76male
77male
78male
79male
80male
81male
82male
83male
84male
85male
86male
87male
88male
89male
90male
91male
92male
93male
94male
95male
96male
97male
98male
99male
100male
Rows: 1-100 of 1234 | Column: sex | Type: Varchar(20)
In [9]:
titanic["sex"].decode("female", 1, "male", 0, 2)
titanic["sex"]
Out[9]:
123
sex
Integer
11
20
31
40
50
60
70
80
90
100
110
120
130
140
150
160
170
180
190
200
210
220
230
240
250
260
270
280
290
300
310
320
330
340
351
360
370
380
390
400
410
420
430
440
450
460
470
480
490
500
510
520
530
540
550
560
571
580
590
600
610
620
630
640
650
660
670
680
690
700
710
720
730
740
750
760
770
780
790
800
810
820
830
840
850
860
870
880
890
900
910
920
930
940
950
960
970
980
990
1000
Rows: 1-100 of 1234 | Column: sex | Type: Integer

See Also

vDataFrame[].discretize Discretizes the vcolumn.
vDataFrame[].label_encode Encodes the vcolumn using the Label Encoding.
vDataFrame[].get_dummies Encodes the vcolumn using the One Hot Encoding.
vDataFrame[].mean_encode Encodes the vcolumn using the Mean Encoding of a response.