def standardize_mapping(into):
if not inspect.isclass(into):<EOL><INDENT>if isinstance(into, collections.defaultdict):<EOL><INDENT>return partial(<EOL>collections.defaultdict, into.default_factory)<EOL><DEDENT>into = type(into)<EOL><DEDENT>if not issubclass(into, abc.Mapping):<EOL><INDENT>raise TypeError('<STR_LIT>'.format(into=into))<EOL><DEDENT>elif into == collections.defaultdict:<EOL><INDENT>raise TypeError(<EOL>'<STR_LIT>')<EOL><DEDENT>return into<EOL>
Helper function to standardize a supplied mapping.

.. versionadded:: 0.21.0

Parameters
----------
into : instance or subclass of collections.abc.Mapping
    Must be a class, an initialized collections.defaultdict,
    or an instance of a collections.abc.Mapping subclass.

Returns
-------
mapping : a collections.abc.Mapping subclass or other constructor
    a callable object that can accept an iterator to create
    the desired Mapping.

See Also
--------
DataFrame.to_dict
Series.to_dict