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 fromverticapy
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
AbcempidVarchar(1)100%010is_tempBoolean100%1 1 ✅ 2 2 ❌ 3 3 ❌ 4 4 ✅ Let’s change the data type from bool to int.
data.bool_to_int()
AbcempidVarchar(1)100%123is_tempInt100%1 1 1 2 2 0 3 3 0 4 4 1