text_extensions_for_pandas/io/watson/tables.py
def convert_cols_to_numeric(df_in: pd.DataFrame, columns=None, rows=None, decimal_pt='.',
                            cast_type=float) -> pd.DataFrame:
    """
    Converts inputted columns or rows to numeric format.

    If no columns are given, it converts all elements to numeric types

    Converts to type specified, if not, defaults to ``float`` type

    :param df_in:       dataframe, (table type) to convert
    :param columns:     columns to convert to numeric type, as a list of strings
    :param rows:        rows to convert to numeric type, as a list of strings
    :param decimal_pt:  what symbol is being used as the decimal point (typically ``"."`` or ``","``
    :param cast_type:   type to cast the object to, as a class. Defaults to ``float``

    :return:            the converted table.
    """
    # converts inputted columns or rows to numeric format.
    # if none are given, it converts all elements to numeric types
    # converts to type given
    if columns is None and rows is None:
        columns = df_in.columns
    if columns is None:
        columns = []
    if rows is None:
        rows = []
    df = df_in.copy()

    def convert_val(val):
        return _convert_val_to_numeric(val, cast_type, f'[^0-9{decimal_pt}()-]')

    for column in columns:
        df[column] = df[column].apply(convert_val)
    for row in rows:
        df.loc[row] = df.loc[row].apply(convert_val)

    return df

    Converts inputted columns or rows to numeric format.

    If no columns are given, it converts all elements to numeric types

    Converts to type specified, if not, defaults to ``float`` type

    :param df_in:       dataframe, (table type) to convert
    :param columns:     columns to convert to numeric type, as a list of strings
    :param rows:        rows to convert to numeric type, as a list of strings
    :param decimal_pt:  what symbol is being used as the decimal point (typically ``"."`` or ``","``
    :param cast_type:   type to cast the object to, as a class. Defaults to ``float``

    :return:            the converted table.
    
Converts inputted columns or rows to numeric format.
If no columns are given, it converts all elements to numeric types

Converts to type specified, if not, defaults to ``float`` type
Converts inputted columns or rows to numeric format . If no columns are given it converts all elements to numeric types Converts to type specified if not defaults to ` ` float ` ` type
def convert_cols_to_numeric(df_in: pd.DataFrame, columns=None, rows=None, decimal_pt='.',
                            cast_type=float) -> pd.DataFrame:
    if columns is None and rows is None:
        columns = df_in.columns
    if columns is None:
        columns = []
    if rows is None:
        rows = []
    df = df_in.copy()
    def convert_val(val):
        return _convert_val_to_numeric(val, cast_type, f'[^0-9{decimal_pt}()-]')
    for column in columns:
        df[column] = df[column].apply(convert_val)
    for row in rows:
        df.loc[row] = df.loc[row].apply(convert_val)
    return df
def convert_cols_to_numeric ( df_in : pd . DataFrame , columns = None , rows = None , decimal_pt = '.' , cast_type = float ) -> pd . DataFrame : if columns is None and rows is None : columns = df_in . columns if columns is None : columns = [ ] if rows is None : rows = [ ] df = df_in . copy ( ) def convert_val ( val ) : return _convert_val_to_numeric ( val , cast_type , f'[^0-9{decimal_pt}()-]' ) for column in columns : df [ column ] = df [ column ] . apply ( convert_val ) for row in rows : df . loc [ row ] = df . loc [ row ] . apply ( convert_val ) return df
Converts inputted columns or rows to numeric format.
Converts inputted columns or rows to numeric format .
"""
    Converts inputted columns or rows to numeric format.

    If no columns are given, it converts all elements to numeric types

    Converts to type specified, if not, defaults to ``float`` type

    :param df_in:       dataframe, (table type) to convert
    :param columns:     columns to convert to numeric type, as a list of strings
    :param rows:        rows to convert to numeric type, as a list of strings
    :param decimal_pt:  what symbol is being used as the decimal point (typically ``"."`` or ``","``
    :param cast_type:   type to cast the object to, as a class. Defaults to ``float``

    :return:            the converted table.
    """ # converts inputted columns or rows to numeric format. # if none are given, it converts all elements to numeric types # converts to type given
the converted table.
the converted table .
df_in
pd.DataFrame
dataframe, (table type) to convert
dataframe ( table type ) to convert
columns
columns to convert to numeric type, as a list of strings
columns to convert to numeric type as a list of strings
rows
rows to convert to numeric type, as a list of strings
rows to convert to numeric type as a list of strings
decimal_pt
None
cast_type
type to cast the object to, as a class. Defaults to ``float``
type to cast the object to as a class . Defaults to ` ` float ` `