toucan_data_sdk/utils/generic/clean.py
def clean_dataframe(df, is_slugify=True, threshold=50, rename_cols=None):
    """
    This method is used to:
    - slugify the column names (if slugify is set to True)
    - convert columns to 'category' (if len(unique) < threshold) or 'int'
    - clean the dataframe and rename if necessary
    """
    if is_slugify:
        df = df.rename(columns=slugify)

    df = df.dropna(axis=1, how='all')
    for column in get_category_cols(df, threshold=threshold):
        df[column] = df[column].astype('category')
    for column in get_int_cols(df):
        df[column] = df[column].astype(int)

    if rename_cols is not None:
        df = df.rename(columns=rename_cols)

    return df
def clean_dataframe(df, is_slugify=True, threshold=50, rename_cols=None):
    """
    This method is used to:
    - slugify the column names (if slugify is set to True)
    - convert columns to 'category' (if len(unique) < threshold) or 'int'
    - clean the dataframe and rename if necessary
    """
    if is_slugify:
        df = df.rename(columns=slugify)

    df = df.dropna(axis=1, how='all')
    for column in get_category_cols(df, threshold=threshold):
        df[column] = df[column].astype('category')
    for column in get_int_cols(df):
        df[column] = df[column].astype(int)

    if rename_cols is not None:
        df = df.rename(columns=rename_cols)

    return df
This method is used to:
    - slugify the column names (if slugify is set to True)
    - convert columns to 'category' (if len(unique) < threshold) or 'int'
    - clean the dataframe and rename if necessary