Skip to content

Commit 403249c

Browse files
committed
CLN: Raise ValueError on invalid dtype
1 parent ca35f4c commit 403249c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pandas/core/reshape/reshape.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas.core.dtypes.common import (
1111
_ensure_platform_int,
1212
is_list_like, is_bool_dtype,
13-
needs_i8_conversion, is_sparse)
13+
needs_i8_conversion, is_sparse, is_object_dtype)
1414
from pandas.core.dtypes.cast import maybe_promote
1515
from pandas.core.dtypes.missing import notna
1616

@@ -804,8 +804,8 @@ def get_dummies(data, prefix=None, prefix_sep='_', dummy_na=False,
804804
if dtype is None:
805805
dtype = np.uint8
806806

807-
if np.dtype(dtype) is np.dtype('O'):
808-
raise TypeError("'object' is not a valid type for get_dummies")
807+
if is_object_dtype(dtype):
808+
raise ValueError("dtype=object is not a valid dtype for get_dummies")
809809

810810
if isinstance(data, DataFrame):
811811
# determine columns being encoded

0 commit comments

Comments
 (0)