vDataFrame.merge_similar_names

In [ ]:
vDataFrame.merge_similar_names(skip_word: list)

Merges columns with similar names. The function generates a COALESCE statement that merges the columns into a single column that excludes the input words. Note that the order of the variables in the COALESCE statement is based on the order of the 'get_columns' method.

Parameters

Name Type Optional Description
skip_word
list
❌
List of words to exclude from the provided column names. For example, if two columns are named 'age.information.phone' and 'age.phone' AND skip_word is set to ['.information'], then the two columns will be merged together with the following COALESCE statement: COALESCE("age.phone", "age.information.phone") AS "age.phone"

Returns

vDataFrame : An object containing the merged element.

Example

In [1]:
from verticapy.utilities import tablesample
x = tablesample(
    {
        "age": [50, None, None, None],
        "information.age": [None, None, 30, None],
        "dict.age": [None, 80, None, None],
        "age.people": [None, None, None, 10],
        "num": [1, 2, 3, 4],
    }
).to_vdf()
x
Out[1]:
123
age
Integer
123
information.age
Integer
123
dict.age
Integer
123
age.people
Integer
123
num
Integer
150[null][null][null]1
2[null][null]80[null]2
3[null]30[null][null]3
4[null][null][null]104
Rows: 1-4 | Columns: 5
In [2]:
x.merge_similar_names(skip_word=["information.", "dict.", ".people"])
Out[2]:
123
age
Integer
123
num
Integer
1501
2802
3303
4104
Rows: 1-4 | Columns: 2