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" |
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]:
In [2]:
x.merge_similar_names(skip_word=["information.", "dict.", ".people"])
Out[2]:
