Loading...

verticapy.vDataFrame.bool_to_int#

vDataFrame.bool_to_int() vDataFrame#

Converts all booleans vDataColumns to integers.

Returns#

vDataFrame

self

Examples#

We import verticapy:

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

Let’s create a small dataset:

data = vp.vDataFrame(
    {
        "empid": ['1', '2', '3', '4'],
        "is_temp": [True, False, False, True],
    }
)
data
Abc
empid
Varchar(1)
100%
010
is_temp
Boolean
100%
11
22
33
44

Let’s change the data type from bool to int.

data.bool_to_int()
Abc
empid
Varchar(1)
100%
123
is_temp
Int
100%
111
220
330
441