def from_pandas_df(df, i_variables, d_variable, alpha_merge=0.05, max_depth=2,
                       min_parent_node_size=30, min_child_node_size=30, split_threshold=0,
                       weight=None, dep_variable_type='categorical'):
        """
        Helper method to pre-process a pandas data frame in order to run CHAID
        analysis

        Parameters
        ----------
        df : pandas.DataFrame
            the dataframe with the dependent and independent variables in which
            to slice from
        i_variables : dict
            dict of instance variable names with their variable types. Supported
            variable types are the strings 'nominal' or 'ordinal' in lower case
        d_variable : string
            the name of the dependent variable in the dataframe
        alpha_merge : float
            the threshold value in which to create a split (default 0.05)
        max_depth : float
            the threshold value for the maximum number of levels after the root
            node in the tree (default 2)
        split_threshold : float
            the variation in chi-score such that surrogate splits are created
            (default 0)
        min_parent_node_size : float
            the threshold value of the number of respondents that the node must
            contain (default 30)
        min_child_node_size : float
            the threshold value of the number of respondents that each child node must
            contain (default 30)
        weight : array-like
            the respondent weights. If passed, weighted chi-square calculation is run
        dep_variable_type : str
            the type of dependent variable. Supported variable types are 'categorical' or
            'continuous'
        """
        ind_df = df[list(i_variables.keys())]
        ind_values = ind_df.values
        dep_values = df[d_variable].values
        weights = df[weight] if weight is not None else None
        return Tree.from_numpy(ind_values, dep_values, alpha_merge, max_depth, min_parent_node_size,
                    min_child_node_size, list(ind_df.columns.values), split_threshold, weights,
                    list(i_variables.values()), dep_variable_type)