def _replace_by_str(data_type_to_replace, data_types):
    """Replace the given data types with the type string.

    Returns a new datatype dictionary in which all occurrences of
    data_type_to_replace have been replaced by type string.

    For example, this function is used to replace the datatypes
    'category' and 'np.bool' by 'str' before reading the csv file.
    """
    # replaces data_type_to_replace by str in data_types
    new_data_types = data_types.copy()
    for key, value in data_types.items():
        if value == data_type_to_replace:
            new_data_types[key] = str

    return new_data_types