text_extensions_for_pandas/io/watson/tables.py
def make_table(dfs_dict: Dict[str, pd.DataFrame], value_col="text", row_explode_by: str = None,
               col_explode_by: str = None, concat_with: str = " | ", convert_numeric_items:bool =True,
               sort_headers:bool=True, prevent_id_explode:bool =False):
    """
    Runs the end-to-end process of creating the table, starting with the parsed response from the Compare & Comply or
    Watson Discovery engine, and returns the completed table.

    :param dfs_dict: The dictionary of {features : DataFrames} returned by watson_tables_parse_response
    :param value_col: Which column to use as values. by default "text"
    :param row_explode_by: If specified, set the method used to explode rows, instead of the default logic being applied
                                if "title", the title field will be used to arrange rows
                                if "title_id", the title_id feild will be used to arrange rows
                                if "index", the row / column locations given will be used to arrange rows
    :param col_explode_by: if specified, set the method used to explode columns, instead of the default logic bing applied
                                if "title", the title field will be used to arrange rows
                                if "title_id", the title_id feild will be used to arrange rows
                                if "index", the row / column locations given will be used to arrange rows
    :param concat_with: the delimiter to use when concatinating duplicate entries. Using an empty string, "" will fuse
                                entries
    :param convert_numeric_items: if `True`, auto-detect and convert numeric rows and columns to numeric datatypes
    :param sort_headers: If ``True`` the headers will be sorted into their original ordering from the table.
                                Will be a little slower. Note: sorting headers is still experimental on multindex tables
                                where not all headers have the same number of elements
    :param prevent_id_explode: If ``True``, prevents default behaviour of exploding by index, which creates
                                higher-fidelity versions of the parsed output, but may make more complex
                                and less idiomatic tables. This does not affect behaviour when either `row_explode_by`
                                or `column_explode_by` are set to `"title_id"`

    :return: the reconstructed table. should be a 1:1 translation of original table

    """
    #use special mode if no explode by method is specified; explode by id then substitute names
    row_headers_by_id = row_explode_by is None and not prevent_id_explode
    col_headers_by_id = col_explode_by is None and not prevent_id_explode
    row_explode_by = "title_id" if row_headers_by_id else row_explode_by
    col_explode_by = "title_id" if col_headers_by_id else col_explode_by

    exploded, row_heading_names, col_heading_names = make_exploded_df(dfs_dict, row_explode_by=row_explode_by,
                                                                      col_explode_by=col_explode_by,
                                                                      keep_all_cols=True)
    table =  make_table_from_exploded_df(exploded, row_heading_names, col_heading_names,
                                       value_col=value_col, concat_with=concat_with,
                                       convert_numeric_items=convert_numeric_items, dfs_dict=dfs_dict,
                                       sort_headers=sort_headers)
    table = substitute_text_names(table,dfs_dict,row_headers_by_id,col_headers_by_id)
    return table

    Runs the end-to-end process of creating the table, starting with the parsed response from the Compare & Comply or
    Watson Discovery engine, and returns the completed table.

    :param dfs_dict: The dictionary of {features : DataFrames} returned by watson_tables_parse_response
    :param value_col: Which column to use as values. by default "text"
    :param row_explode_by: If specified, set the method used to explode rows, instead of the default logic being applied
                                if "title", the title field will be used to arrange rows
                                if "title_id", the title_id feild will be used to arrange rows
                                if "index", the row / column locations given will be used to arrange rows
    :param col_explode_by: if specified, set the method used to explode columns, instead of the default logic bing applied
                                if "title", the title field will be used to arrange rows
                                if "title_id", the title_id feild will be used to arrange rows
                                if "index", the row / column locations given will be used to arrange rows
    :param concat_with: the delimiter to use when concatinating duplicate entries. Using an empty string, "" will fuse
                                entries
    :param convert_numeric_items: if `True`, auto-detect and convert numeric rows and columns to numeric datatypes
    :param sort_headers: If ``True`` the headers will be sorted into their original ordering from the table.
                                Will be a little slower. Note: sorting headers is still experimental on multindex tables
                                where not all headers have the same number of elements
    :param prevent_id_explode: If ``True``, prevents default behaviour of exploding by index, which creates
                                higher-fidelity versions of the parsed output, but may make more complex
                                and less idiomatic tables. This does not affect behaviour when either `row_explode_by`
                                or `column_explode_by` are set to `"title_id"`

    :return: the reconstructed table. should be a 1:1 translation of original table

    
Runs the end-to-end process of creating the table, starting with the parsed response from the Compare & Comply or
Watson Discovery engine, and returns the completed table.
Runs the end - to - end process of creating the table starting with the parsed response from the Compare & Comply or Watson Discovery engine and returns the completed table .
def make_table(dfs_dict: Dict[str, pd.DataFrame], value_col="text", row_explode_by: str = None,
               col_explode_by: str = None, concat_with: str = " | ", convert_numeric_items:bool =True,
               sort_headers:bool=True, prevent_id_explode:bool =False):
    row_headers_by_id = row_explode_by is None and not prevent_id_explode
    col_headers_by_id = col_explode_by is None and not prevent_id_explode
    row_explode_by = "title_id" if row_headers_by_id else row_explode_by
    col_explode_by = "title_id" if col_headers_by_id else col_explode_by
    exploded, row_heading_names, col_heading_names = make_exploded_df(dfs_dict, row_explode_by=row_explode_by,
                                                                      col_explode_by=col_explode_by,
                                                                      keep_all_cols=True)
    table =  make_table_from_exploded_df(exploded, row_heading_names, col_heading_names,
                                       value_col=value_col, concat_with=concat_with,
                                       convert_numeric_items=convert_numeric_items, dfs_dict=dfs_dict,
                                       sort_headers=sort_headers)
    table = substitute_text_names(table,dfs_dict,row_headers_by_id,col_headers_by_id)
    return table
def make_table ( dfs_dict : Dict [ str , pd . DataFrame ] , value_col = "text" , row_explode_by : str = None , col_explode_by : str = None , concat_with : str = " | " , convert_numeric_items : bool = True , sort_headers : bool = True , prevent_id_explode : bool = False ) : row_headers_by_id = row_explode_by is None and not prevent_id_explode col_headers_by_id = col_explode_by is None and not prevent_id_explode row_explode_by = "title_id" if row_headers_by_id else row_explode_by col_explode_by = "title_id" if col_headers_by_id else col_explode_by exploded , row_heading_names , col_heading_names = make_exploded_df ( dfs_dict , row_explode_by = row_explode_by , col_explode_by = col_explode_by , keep_all_cols = True ) table = make_table_from_exploded_df ( exploded , row_heading_names , col_heading_names , value_col = value_col , concat_with = concat_with , convert_numeric_items = convert_numeric_items , dfs_dict = dfs_dict , sort_headers = sort_headers ) table = substitute_text_names ( table , dfs_dict , row_headers_by_id , col_headers_by_id ) return table
Runs the end-to-end process of creating the table, starting with the parsed response from the Compare & Comply or
Watson Discovery engine, and returns the completed table.
Runs the end - to - end process of creating the table starting with the parsed response from the Compare & Comply or Watson Discovery engine and returns the completed table .
"""
    Runs the end-to-end process of creating the table, starting with the parsed response from the Compare & Comply or
    Watson Discovery engine, and returns the completed table.

    :param dfs_dict: The dictionary of {features : DataFrames} returned by watson_tables_parse_response
    :param value_col: Which column to use as values. by default "text"
    :param row_explode_by: If specified, set the method used to explode rows, instead of the default logic being applied
                                if "title", the title field will be used to arrange rows
                                if "title_id", the title_id feild will be used to arrange rows
                                if "index", the row / column locations given will be used to arrange rows
    :param col_explode_by: if specified, set the method used to explode columns, instead of the default logic bing applied
                                if "title", the title field will be used to arrange rows
                                if "title_id", the title_id feild will be used to arrange rows
                                if "index", the row / column locations given will be used to arrange rows
    :param concat_with: the delimiter to use when concatinating duplicate entries. Using an empty string, "" will fuse
                                entries
    :param convert_numeric_items: if `True`, auto-detect and convert numeric rows and columns to numeric datatypes
    :param sort_headers: If ``True`` the headers will be sorted into their original ordering from the table.
                                Will be a little slower. Note: sorting headers is still experimental on multindex tables
                                where not all headers have the same number of elements
    :param prevent_id_explode: If ``True``, prevents default behaviour of exploding by index, which creates
                                higher-fidelity versions of the parsed output, but may make more complex
                                and less idiomatic tables. This does not affect behaviour when either `row_explode_by`
                                or `column_explode_by` are set to `"title_id"`

    :return: the reconstructed table. should be a 1:1 translation of original table

    """ #use special mode if no explode by method is specified; explode by id then substitute names
the reconstructed table. should be a 1:1 translation of original table
the reconstructed table . should be a 1 : 1 translation of original table
dfs_dict
Dict[str, pd.DataFrame]
The dictionary of {features : DataFrames} returned by watson_tables_parse_response
The dictionary of { features : DataFrames } returned by watson_tables_parse_response
value_col
Which column to use as values. by default "text"
Which column to use as values . by default " text "
row_explode_by
str
If specified, set the method used to explode rows, instead of the default logic being applied
if "title", the title field will be used to arrange rows
if "title_id", the title_id feild will be used to arrange rows
if "index", the row / column locations given will be used to arrange rows
If specified set the method used to explode rows instead of the default logic being applied if " title " the title field will be used to arrange rows if " title_id " the title_id feild will be used to arrange rows if " index " the row / column locations given will be used to arrange rows
col_explode_by
str
if specified, set the method used to explode columns, instead of the default logic bing applied
if "title", the title field will be used to arrange rows
if "title_id", the title_id feild will be used to arrange rows
if "index", the row / column locations given will be used to arrange rows
if specified set the method used to explode columns instead of the default logic bing applied if " title " the title field will be used to arrange rows if " title_id " the title_id feild will be used to arrange rows if " index " the row / column locations given will be used to arrange rows
concat_with
str
the delimiter to use when concatinating duplicate entries. Using an empty string, "" will fuse
entries
the delimiter to use when concatinating duplicate entries . Using an empty string " " will fuse entries
convert_numeric_items
bool
if `True`, auto-detect and convert numeric rows and columns to numeric datatypes
if ` True ` auto - detect and convert numeric rows and columns to numeric datatypes
sort_headers
bool
If ``True`` the headers will be sorted into their original ordering from the table.
Will be a little slower. Note: sorting headers is still experimental on multindex tables
where not all headers have the same number of elements
If ` ` True ` ` the headers will be sorted into their original ordering from the table . Will be a little slower . Note : sorting headers is still experimental on multindex tables where not all headers have the same number of elements
prevent_id_explode
bool
If ``True``, prevents default behaviour of exploding by index, which creates
higher-fidelity versions of the parsed output, but may make more complex
and less idiomatic tables. This does not affect behaviour when either `row_explode_by`
or `column_explode_by` are set to `"title_id"`
If ` ` True ` ` prevents default behaviour of exploding by index which creates higher - fidelity versions of the parsed output but may make more complex and less idiomatic tables . This does not affect behaviour when either ` row_explode_by ` or ` column_explode_by ` are set to ` " title_id " `