Loading...

verticapy.vDataFrame.get_columns#

vDataFrame.get_columns(exclude_columns: str | list[str] | None = None) list[str]#

Returns the vDataFrame vDataColumns.

Parameters#

exclude_columns: SQLColumns, optional

List of the vDataColumns names to exclude from the final list.

Returns#

List

List of all vDataFrame columns.

Examples#

Let’s begin by importing 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 us create a vDataFrame with multiple columns:

vdf = vp.vDataFrame(
    {
        "col1": [1, 2, 3],
        "col2": [1, 2, 3],
        "col3": [1, 2, 3],
        "col4": [1, 2, 3],
    }
)

123
col1
Integer
100%
...
123
col2
Integer
100%
123
col4
Integer
100%
11...11
22...22
33...33

We can get the column names by:

vdf.get_columns()
Out[3]: ['"col1"', '"col2"', '"col3"', '"col4"']

Some columns could also be directly excluded:

vdf.get_columns(exclude_columns = "col1")
Out[4]: ['"col2"', '"col3"', '"col4"']

See also

vDataFrame.head() : Get head of the vDataFrame.
vDataColumn.tail() : Get tail of the vDataFrame.