Loading...

verticapy.vDataColumn.rename#

vDataColumn.rename(new_name: str) vDataFrame#

Renames the vDataColumn by dropping the current vDataColumn and creating a copy with the specified name.

Warning

SQL code generation will be slower if the vDataFrame has been transformed multiple times, so it’s better practice to use this method when first preparing your data.

Parameters#

new_name: str

The new vDataColumn alias.

Returns#

vDataFrame

self._parent

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 dummy dataset and rename one of its columns:

vdf = vp.vDataFrame(
    {
        "val" : [0, 10, 20],
        "cat": ['a', 'b', 'c'],
    },
)

123
val
Integer
100%
Abc
cat
Varchar(1)
100%
10a
210b
320c

We can copy the “val” column, and name the new column:

vdf["val"].rename("value")
Abc
cat
Varchar(1)
100%
123
value
Integer
100%
1a0
2b10
3c20

See also

vDataColumn.add_copy() : Adds a copy vDataColumn to the parent vDataFrame.