def type_convert_mode(dataframe, colname, data_type):
    """Replace mistyped values with the modal value on dataframe[colname]"""
    col = dataframe[colname]
    col_this_type = col.loc[col.apply(lambda x: isinstance(x, data_type))]
    dataframe.loc[col.notnull() & col.apply(lambda x: not isinstance(x,
        data_type)), colname] = col_this_type.mode().get(0, None)
    return dataframe
