def pandas_dtype(dtype):
<EOL>if isinstance(dtype, np.ndarray):<EOL><INDENT>return dtype.dtype<EOL><DEDENT>elif isinstance(dtype, (np.dtype, PandasExtensionDtype, ExtensionDtype)):<EOL><INDENT>return dtype<EOL><DEDENT>result = registry.find(dtype)<EOL>if result is not None:<EOL><INDENT>return result<EOL><DEDENT>try:<EOL><INDENT>npdtype = np.dtype(dtype)<EOL><DEDENT>except Exception:<EOL><INDENT>if not isinstance(dtype, str):<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT>raise TypeError("<STR_LIT>".format(<EOL>dtype))<EOL><DEDENT>if is_hashable(dtype) and dtype in [object, np.object_, '<STR_LIT:object>', '<STR_LIT:O>']:<EOL><INDENT>return npdtype<EOL><DEDENT>elif npdtype.kind == '<STR_LIT:O>':<EOL><INDENT>raise TypeError("<STR_LIT>".format(dtype))<EOL><DEDENT>return npdtype<EOL>
Convert input into a pandas only dtype object or a numpy dtype object.

Parameters
----------
dtype : object to be converted

Returns
-------
np.dtype or a pandas dtype

Raises
------
TypeError if not a dtype