Skip to content

Raising for invalid dtype issue #15520 #15576

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def _validate_dtype(self, dtype):
raise NotImplementedError("compound dtypes are not implemented"
"in the {0} constructor"
.format(self.__class__.__name__))

# check if coerced dtype is of type object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pandas.types.common.pandas_dtype

if dtype.kind == 'O':
raise TypeError("argument 'dtype' must be a valid "
"pandas/numpy dtype")

return dtype

def _init_mgr(self, mgr, axes=None, dtype=None, copy=False):
Expand Down