def filter_data(records, filters):
    """ Returns records with column entries that contain user-provided terms.

    For each key (column name) in 'filters', a list of required terms is given.
    Returned records must contain at least one of the listed terms per
    key/column.  For any catalogue column that is not a key in the dictionary,
    no filtering will occur.  An empty filter dictionary returns all records.

    Args:
        records (pd.DataFrame): Dataframe containing CDLI records.
        filters (dict of str -> list): Maps catalogue column names to a list of
            required terms.

    Returns:
        records (pd.DataFrame): Dataframe containing CDLI records after filtering.

    """
    for column, allowed in filters.items():
        allowed_entries = []

        for entry in allowed:
            allowed_entries.extend([val for val
                                    in records[column].str.lower().unique()
                                    if entry.lower() in val])

        records = records[records[column].str.lower().isin(allowed_entries)]
    return records