text_extensions_for_pandas/io/watson/tables.py
def _order_multiindex(headers, exploded_col, spot, header_df):
    """
    recursive function that orders a subset of headers of a multiindex table
    :param headers: the multiindex headers to be operating on
    :param exploded_col: the list of columns in the exploded set to act on
    :param spot: which header to act on; used for recursion accross multiindex sets
    :param header_df: the "row_header" or "column_header" dataframe, with the subset of headers used.

    :return:
    """
    uniques = headers[spot].unique()
    uniques_sorted = header_df[header_df["text"].isin(uniques)].sort_values("column_index_begin")[
        "text"].drop_duplicates().to_list()
    ans = []
    for unique in uniques_sorted:
        if spot < (len(exploded_col) - 1):
            arr = _order_multiindex(headers.loc[unique], exploded_col, spot + 1, header_df)
            for ar in arr:
                ar.insert(0, unique)
                ans.append(ar)
        else:
            ans.append([unique])
    return ans

    recursive function that orders a subset of headers of a multiindex table
    :param headers: the multiindex headers to be operating on
    :param exploded_col: the list of columns in the exploded set to act on
    :param spot: which header to act on; used for recursion accross multiindex sets
    :param header_df: the "row_header" or "column_header" dataframe, with the subset of headers used.

    :return:
    
recursive function that orders a subset of headers of a multiindex table
recursive function that orders a subset of headers of a multiindex table
def _order_multiindex(headers, exploded_col, spot, header_df):
    uniques = headers[spot].unique()
    uniques_sorted = header_df[header_df["text"].isin(uniques)].sort_values("column_index_begin")[
        "text"].drop_duplicates().to_list()
    ans = []
    for unique in uniques_sorted:
        if spot < (len(exploded_col) - 1):
            arr = _order_multiindex(headers.loc[unique], exploded_col, spot + 1, header_df)
            for ar in arr:
                ar.insert(0, unique)
                ans.append(ar)
        else:
            ans.append([unique])
    return ans
def _order_multiindex ( headers , exploded_col , spot , header_df ) : uniques = headers [ spot ] . unique ( ) uniques_sorted = header_df [ header_df [ "text" ] . isin ( uniques ) ] . sort_values ( "column_index_begin" ) [ "text" ] . drop_duplicates ( ) . to_list ( ) ans = [ ] for unique in uniques_sorted : if spot < ( len ( exploded_col ) - 1 ) : arr = _order_multiindex ( headers . loc [ unique ] , exploded_col , spot + 1 , header_df ) for ar in arr : ar . insert ( 0 , unique ) ans . append ( ar ) else : ans . append ( [ unique ] ) return ans
recursive function that orders a subset of headers of a multiindex table
recursive function that orders a subset of headers of a multiindex table
"""
    recursive function that orders a subset of headers of a multiindex table
    :param headers: the multiindex headers to be operating on
    :param exploded_col: the list of columns in the exploded set to act on
    :param spot: which header to act on; used for recursion accross multiindex sets
    :param header_df: the "row_header" or "column_header" dataframe, with the subset of headers used.

    :return:
    """
None
headers
the multiindex headers to be operating on
the multiindex headers to be operating on
exploded_col
the list of columns in the exploded set to act on
the list of columns in the exploded set to act on
spot
which header to act on; used for recursion accross multiindex sets
which header to act on ; used for recursion accross multiindex sets
header_df
the "row_header" or "column_header" dataframe, with the subset of headers used.
the " row_header " or " column_header " dataframe with the subset of headers used .