def _merge_by_type(usage_types, missing_values, unusual_changes_by_type):
    """Merge the contents of dicts `missing_values` and
    `unusual_changes_by_type`. The result will have the following form:
    {
        <UsageType>: {
            'unusual_changes': [
                (datetime.date, datetime.date, float, float, float),
                ...
             ],
            'missing_values': [
                datetime.date,
                ...
            ],
        },
    }
    """
    merged_anomalies = {}
    for usage_type in usage_types:
        unusual_changes = unusual_changes_by_type.get(usage_type)
        missing_values_ = missing_values.get(usage_type)
        if unusual_changes is None and missing_values is None:
            continue
        merged_anomalies[usage_type] = {
            'unusual_changes': unusual_changes,
            'missing_values': missing_values_,
        }
    return merged_anomalies