def ibis_schema_apply_to(schema, df):
    """Applies the Ibis schema to a pandas DataFrame

    Parameters
    ----------
    schema : ibis.schema.Schema
    df : pandas.DataFrame

    Returns
    -------
    df : pandas.DataFrame

    Notes
    -----
    Mutates `df`
    """

    for column, dtype in schema.items():
        pandas_dtype = dtype.to_pandas()
        col = df[column]
        col_dtype = col.dtype

        try:
            not_equal = pandas_dtype != col_dtype
        except TypeError:
            # ugh, we can't compare dtypes coming from pandas, assume not equal
            not_equal = True

        if not_equal or dtype == dt.string:
            df[column] = convert(col_dtype, dtype, col)

    return df
def ibis_schema_apply_to ( schema , df ) : for column , dtype in schema . items ( ) : pandas_dtype = dtype . to_pandas ( ) col = df [ column ] col_dtype = col . dtype try : not_equal = pandas_dtype != col_dtype except TypeError : not_equal = True if not_equal or dtype == dt . string : df [ column ] = convert ( col_dtype , dtype , col ) return df
Applies the Ibis schema to a pandas DataFrame

    Parameters
    ----------
    schema : ibis.schema.Schema
    df : pandas.DataFrame

    Returns
    -------
    df : pandas.DataFrame

    Notes
    -----
    Mutates `df`