def ensure_columns_are_in_dataframe(columns,
                                    dataframe,
                                    col_title='',
                                    data_title='data'):
    """
    Checks whether each column in `columns` is in `dataframe`. Raises
    ValueError if any of the columns are not in the dataframe.

    Parameters
    ----------
    columns : list of strings.
        Each string should represent a column heading in dataframe.
    dataframe : pandas DataFrame.
        Dataframe containing the data for the choice model to be estimated.
    col_title : str, optional.
        Denotes the title of the columns that were passed to the function.
    data_title : str, optional.
        Denotes the title of the dataframe that is being checked to see whether
        it contains the passed columns. Default == 'data'

    Returns
    -------
    None.
    """
    # Make sure columns is an iterable
    assert isinstance(columns, Iterable)
    # Make sure dataframe is a pandas dataframe
    assert isinstance(dataframe, pd.DataFrame)
    # Make sure title is a string
    assert isinstance(col_title, str)
    assert isinstance(data_title, str)

    problem_cols = [col for col in columns if col not in dataframe.columns]
    if problem_cols != []:
        if col_title == '':
            msg = "{} not in {}.columns"
            final_msg = msg.format(problem_cols, data_title)
        else:
            msg = "The following columns in {} are not in {}.columns: {}"
            final_msg = msg.format(col_title, data_title, problem_cols)

        raise ValueError(final_msg)

    return None
Checks whether each column in `columns` is in `dataframe`. Raises
    ValueError if any of the columns are not in the dataframe.

    Parameters
    ----------
    columns : list of strings.
        Each string should represent a column heading in dataframe.
    dataframe : pandas DataFrame.
        Dataframe containing the data for the choice model to be estimated.
    col_title : str, optional.
        Denotes the title of the columns that were passed to the function.
    data_title : str, optional.
        Denotes the title of the dataframe that is being checked to see whether
        it contains the passed columns. Default == 'data'

    Returns
    -------
    None.