text_extensions_for_pandas/io/watson/tables.py
def _infer_numeric_rows_cols(exploded_df, row_names, col_names):
    """
    intakes the exploded format of the dataframe, and uses it to infer which set of rows or columns are supposed to be
        numeric, then returns them as a list
    :param exploded_df: the exploded dataframe, (penultimate step of table reconstruction)
    :param row_names: the header names of columns in the exploded dataframe indicating row headers,
            (as returned from ``make_exploded_df()``)
    :param col_names: the header names of columns in the exploded dataframe indicating column headers,
            (as returned from ``make_exploded_df()``)
    :return: a tuple, in the form ``(numeric_rows, numeric_columns)`` where one of ``numeric_rows`` or
            ``numeric_columns`` is an empty list, and the other contains all row/columns that are of numeric type
    """
    list_of_numeric_labels = ["Number", "Percentage"]

    numeric_cells = _generate_is_numeric_table(exploded_df, row_names, col_names)

    cols = []
    rows = []
    axis = None

    # if rows are unnamed they very likely are not numeric
    if row_names == ['row_index'] and not col_names == ['column_index']:
        axis = 0  # row centric
    elif col_names == ['column_index'] and not row_names == ['row_index']:
        axis = 1  # col centric
    else:
        # columns/rows with higher variance between numeric and non-numeric less likely to be the primary direction
        col_score = numeric_cells.std(axis=0).mean()
        row_score = numeric_cells.std(axis=1).mean()
        axis = 1 if col_score > row_score else 0

    is_num_scores = numeric_cells.sum(axis=axis) / numeric_cells.shape[axis]
    if axis == 1:
        rows = (is_num_scores[is_num_scores > .9].index.to_list())
    elif axis == 0:
        cols = (is_num_scores[is_num_scores > .9].index.to_list())

    return rows, cols

    intakes the exploded format of the dataframe, and uses it to infer which set of rows or columns are supposed to be
        numeric, then returns them as a list
    :param exploded_df: the exploded dataframe, (penultimate step of table reconstruction)
    :param row_names: the header names of columns in the exploded dataframe indicating row headers,
            (as returned from ``make_exploded_df()``)
    :param col_names: the header names of columns in the exploded dataframe indicating column headers,
            (as returned from ``make_exploded_df()``)
    :return: a tuple, in the form ``(numeric_rows, numeric_columns)`` where one of ``numeric_rows`` or
            ``numeric_columns`` is an empty list, and the other contains all row/columns that are of numeric type
    
intakes the exploded format of the dataframe, and uses it to infer which set of rows or columns are supposed to be
numeric, then returns them as a list
intakes the exploded format of the dataframe and uses it to infer which set of rows or columns are supposed to be numeric then returns them as a list
def _infer_numeric_rows_cols(exploded_df, row_names, col_names):
    list_of_numeric_labels = ["Number", "Percentage"]
    numeric_cells = _generate_is_numeric_table(exploded_df, row_names, col_names)
    cols = []
    rows = []
    axis = None
    if row_names == ['row_index'] and not col_names == ['column_index']:
        axis = 0  
    elif col_names == ['column_index'] and not row_names == ['row_index']:
        axis = 1  
    else:
        col_score = numeric_cells.std(axis=0).mean()
        row_score = numeric_cells.std(axis=1).mean()
        axis = 1 if col_score > row_score else 0
    is_num_scores = numeric_cells.sum(axis=axis) / numeric_cells.shape[axis]
    if axis == 1:
        rows = (is_num_scores[is_num_scores > .9].index.to_list())
    elif axis == 0:
        cols = (is_num_scores[is_num_scores > .9].index.to_list())
    return rows, cols
def _infer_numeric_rows_cols ( exploded_df , row_names , col_names ) : list_of_numeric_labels = [ "Number" , "Percentage" ] numeric_cells = _generate_is_numeric_table ( exploded_df , row_names , col_names ) cols = [ ] rows = [ ] axis = None if row_names == [ 'row_index' ] and not col_names == [ 'column_index' ] : axis = 0 elif col_names == [ 'column_index' ] and not row_names == [ 'row_index' ] : axis = 1 else : col_score = numeric_cells . std ( axis = 0 ) . mean ( ) row_score = numeric_cells . std ( axis = 1 ) . mean ( ) axis = 1 if col_score > row_score else 0 is_num_scores = numeric_cells . sum ( axis = axis ) / numeric_cells . shape [ axis ] if axis == 1 : rows = ( is_num_scores [ is_num_scores > .9 ] . index . to_list ( ) ) elif axis == 0 : cols = ( is_num_scores [ is_num_scores > .9 ] . index . to_list ( ) ) return rows , cols
intakes the exploded format of the dataframe, and uses it to infer which set of rows or columns are supposed to be
numeric, then returns them as a list
intakes the exploded format of the dataframe and uses it to infer which set of rows or columns are supposed to be numeric then returns them as a list
"""
    intakes the exploded format of the dataframe, and uses it to infer which set of rows or columns are supposed to be
        numeric, then returns them as a list
    :param exploded_df: the exploded dataframe, (penultimate step of table reconstruction)
    :param row_names: the header names of columns in the exploded dataframe indicating row headers,
            (as returned from ``make_exploded_df()``)
    :param col_names: the header names of columns in the exploded dataframe indicating column headers,
            (as returned from ``make_exploded_df()``)
    :return: a tuple, in the form ``(numeric_rows, numeric_columns)`` where one of ``numeric_rows`` or
            ``numeric_columns`` is an empty list, and the other contains all row/columns that are of numeric type
    """ # if rows are unnamed they very likely are not numeric # row centric # col centric # columns/rows with higher variance between numeric and non-numeric less likely to be the primary direction
a tuple, in the form ``(numeric_rows, numeric_columns)`` where one of ``numeric_rows`` or
``numeric_columns`` is an empty list, and the other contains all row/columns that are of numeric type
a tuple in the form ` ` ( numeric_rows numeric_columns ) ` ` where one of ` ` numeric_rows ` ` or ` ` numeric_columns ` ` is an empty list and the other contains all row / columns that are of numeric type
exploded_df
the exploded dataframe, (penultimate step of table reconstruction)
the exploded dataframe ( penultimate step of table reconstruction )
row_names
the header names of columns in the exploded dataframe indicating row headers,
(as returned from ``make_exploded_df()``)
the header names of columns in the exploded dataframe indicating row headers ( as returned from ` ` make_exploded_df () ` ` )
col_names
the header names of columns in the exploded dataframe indicating column headers,
(as returned from ``make_exploded_df()``)
the header names of columns in the exploded dataframe indicating column headers ( as returned from ` ` make_exploded_df () ` ` )