Loading...

verticapy.vDataFrame.drop#

vDataFrame.drop(columns: str | list[str] | None = None) vDataFrame#

Drops the input vDataColumns from the vDataFrame. Dropping vDataColumns means they are not selected in the final SQL code generation.

Warning

Be careful when using this method. It can make the vDataFrame structure heavier if other vDataColumns are computed using the dropped vDataColumns.

Parameters#

columns: SQLColumns, optional

List of the vDataColumns names.

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.

For this example, we will use a dummy dataset with three columns:

vdf = vp.vDataFrame(
    {
        "col1": [1, 2, 3],
        "col2": [3, 3, 1],
        "col":['a', 'b', 'v']
    }
)

123
col1
Integer
100%
...
123
col2
Integer
100%
Abc
col
Varchar(1)
100%
11...3a
22...3b
33...1v

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

Using drop we can take out any column that we do not need:

vdf.drop("col1")
Out[3]: 
None  col2    col  
1       3      a  
2       3      b  
3       1      v  
Rows: 3 | Columns: 2
123
col2
Integer
100%
Abc
col
Varchar(1)
100%
13a
23b
31v

See also

vDataFrame.balance() : Balances the vDataFrame.
vDataFrame.drop_duplicates() : Drops the vDataFrame duplicates.