def _format_map_output(self, result_format, success, element_count, nonnull_count, unexpected_count, unexpected_list, unexpected_index_list):
    'Helper function to construct expectation result objects for map_expectations (such as column_map_expectation\n        and file_lines_map_expectation).\n\n        Expectations support four result_formats: BOOLEAN_ONLY, BASIC, SUMMARY, and COMPLETE.\n        In each case, the object returned has a different set of populated fields.\n        See :ref:`result_format` for more information.\n\n        This function handles the logic for mapping those fields for column_map_expectations.\n        '
    result_format = parse_result_format(result_format)
    return_obj = {'success': success}
    if (result_format['result_format'] == 'BOOLEAN_ONLY'):
        return return_obj
    missing_count = (element_count - nonnull_count)
    if (element_count > 0):
        missing_percent = ((missing_count / element_count) * 100)
        if (nonnull_count > 0):
            unexpected_percent_total = ((unexpected_count / element_count) * 100)
            unexpected_percent_nonmissing = ((unexpected_count / nonnull_count) * 100)
        else:
            unexpected_percent_total = None
            unexpected_percent_nonmissing = None
    else:
        missing_percent = None
        unexpected_percent_total = None
        unexpected_percent_nonmissing = None
    return_obj['result'] = {'element_count': element_count, 'missing_count': missing_count, 'missing_percent': missing_percent, 'unexpected_count': unexpected_count, 'unexpected_percent': unexpected_percent_nonmissing, 'unexpected_percent_total': unexpected_percent_total, 'unexpected_percent_nonmissing': unexpected_percent_nonmissing, 'partial_unexpected_list': unexpected_list[:result_format['partial_unexpected_count']]}
    if (result_format['result_format'] == 'BASIC'):
        return return_obj
    if (0 < result_format.get('partial_unexpected_count')):
        try:
            partial_unexpected_counts = [{'value': key, 'count': value} for (key, value) in sorted(Counter(unexpected_list).most_common(result_format['partial_unexpected_count']), key=(lambda x: ((- x[1]), str(x[0]))))]
        except TypeError:
            partial_unexpected_counts = []
            if ('details' not in return_obj['result']):
                return_obj['result']['details'] = {}
            return_obj['result']['details']['partial_unexpected_counts_error'] = 'partial_unexpected_counts requested, but requires a hashable type'
        finally:
            return_obj['result'].update({'partial_unexpected_index_list': (unexpected_index_list[:result_format['partial_unexpected_count']] if (unexpected_index_list is not None) else None), 'partial_unexpected_counts': partial_unexpected_counts})
    if (result_format['result_format'] == 'SUMMARY'):
        return return_obj
    return_obj['result'].update({'unexpected_list': unexpected_list, 'unexpected_index_list': unexpected_index_list})
    if (result_format['result_format'] == 'COMPLETE'):
        return return_obj
    raise ValueError('Unknown result_format {}.'.format(result_format['result_format']))
Helper function to construct expectation result objects for map_expectations (such as column_map_expectation
and file_lines_map_expectation).

Expectations support four result_formats: BOOLEAN_ONLY, BASIC, SUMMARY, and COMPLETE.
In each case, the object returned has a different set of populated fields.
See :ref:`result_format` for more information.

This function handles the logic for mapping those fields for column_map_expectations.
def _format_map_output(self, result_format, success, element_count, nonnull_count, unexpected_count, unexpected_list, unexpected_index_list):
    'Helper function to construct expectation result objects for map_expectations (such as column_map_expectation\n        and file_lines_map_expectation).\n\n        Expectations support four result_formats: BOOLEAN_ONLY, BASIC, SUMMARY, and COMPLETE.\n        In each case, the object returned has a different set of populated fields.\n        See :ref:`result_format` for more information.\n\n        This function handles the logic for mapping those fields for column_map_expectations.\n        '
    result_format = parse_result_format(result_format)
    return_obj = {'success': success}
    if (result_format['result_format'] == 'BOOLEAN_ONLY'):
        return return_obj
    missing_count = (element_count - nonnull_count)
    if (element_count > 0):
        missing_percent = ((missing_count / element_count) * 100)
        if (nonnull_count > 0):
            unexpected_percent_total = ((unexpected_count / element_count) * 100)
            unexpected_percent_nonmissing = ((unexpected_count / nonnull_count) * 100)
        else:
            unexpected_percent_total = None
            unexpected_percent_nonmissing = None
    else:
        missing_percent = None
        unexpected_percent_total = None
        unexpected_percent_nonmissing = None
    return_obj['result'] = {'element_count': element_count, 'missing_count': missing_count, 'missing_percent': missing_percent, 'unexpected_count': unexpected_count, 'unexpected_percent': unexpected_percent_nonmissing, 'unexpected_percent_total': unexpected_percent_total, 'unexpected_percent_nonmissing': unexpected_percent_nonmissing, 'partial_unexpected_list': unexpected_list[:result_format['partial_unexpected_count']]}
    if (result_format['result_format'] == 'BASIC'):
        return return_obj
    if (0 < result_format.get('partial_unexpected_count')):
        try:
            partial_unexpected_counts = [{'value': key, 'count': value} for (key, value) in sorted(Counter(unexpected_list).most_common(result_format['partial_unexpected_count']), key=(lambda x: ((- x[1]), str(x[0]))))]
        except TypeError:
            partial_unexpected_counts = []
            if ('details' not in return_obj['result']):
                return_obj['result']['details'] = {}
            return_obj['result']['details']['partial_unexpected_counts_error'] = 'partial_unexpected_counts requested, but requires a hashable type'
        finally:
            return_obj['result'].update({'partial_unexpected_index_list': (unexpected_index_list[:result_format['partial_unexpected_count']] if (unexpected_index_list is not None) else None), 'partial_unexpected_counts': partial_unexpected_counts})
    if (result_format['result_format'] == 'SUMMARY'):
        return return_obj
    return_obj['result'].update({'unexpected_list': unexpected_list, 'unexpected_index_list': unexpected_index_list})
    if (result_format['result_format'] == 'COMPLETE'):
        return return_obj
    raise ValueError('Unknown result_format {}.'.format(result_format['result_format']))