SuperNode.split_on_df_column#

SuperNode.split_on_df_column(df, column)[source]#

Splits the node based on the columns of a pandas DataFrame. The number of children nodes will depend on the number of unique values in the column. Each unique value will be the name attribute of a child node.

Parameters:
  • df (pandas.DataFrame) –

  • column – One of the columns of the DataFrame.

Returns:

nodes

Return type:

list of children nodes

Examples

>>> import pandas as pd
>>> df = pd.DataFrame({"Column-1": ["column-1 row-1", "column-1 row-2"],
...                    "Column-2": ["column-2 row-1", "column-2 row-2"]})
>>> node = SuperNode("DataFrame Node")
>>> node.split_on_df_column(df, "Column-1")
[(name=column-1 row-1, value: DataFrame), (name=column-1 row-2, value: DataFrame)]
>>> node
(name=DataFrame Node)
|__ (name=column-1 row-1, value: DataFrame)
|__ (name=column-1 row-2, value: DataFrame)