From 8dad8f9f4e8012a0be23e61cf78f7e06fa491544 Mon Sep 17 00:00:00 2001 From: trevorpburke Date: Sat, 4 Mar 2017 20:08:57 -0800 Subject: [PATCH] Added exception for invalid dtypes per issue #15520 --- pandas/core/series.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 626a4a81193cc..6465264df02e3 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -156,7 +156,11 @@ def __init__(self, data=None, index=None, dtype=None, name=None, if data is None: data = {} if dtype is not None: - dtype = self._validate_dtype(dtype) + if dtype is numpy.dtype or dtype is pandas.dtype: + dtype = self._validate_dtype(dtype) + else: + raise TypeError("Argument 'dtype' must be + numpy.dtype or pandas.dtype") if isinstance(data, MultiIndex): raise NotImplementedError("initializing a Series from a "