|
27 | 27 |
|
28 | 28 | from pandas.core.dtypes.cast import astype_nansafe
|
29 | 29 | from pandas.core.dtypes.common import (
|
30 |
| - ensure_object, is_categorical_dtype, is_dtype_equal, is_float, is_integer, |
31 |
| - is_integer_dtype, is_list_like, is_object_dtype, is_scalar, |
32 |
| - is_string_dtype) |
| 30 | + ensure_object, is_bool_dtype, is_categorical_dtype, is_dtype_equal, |
| 31 | + is_float, is_integer, is_integer_dtype, is_list_like, is_object_dtype, |
| 32 | + is_scalar, is_string_dtype) |
33 | 33 | from pandas.core.dtypes.dtypes import CategoricalDtype
|
34 | 34 | from pandas.core.dtypes.missing import isna
|
35 | 35 |
|
@@ -2435,6 +2435,20 @@ def _clean_mapping(mapping):
|
2435 | 2435 | clean_na_values = self.na_values
|
2436 | 2436 | clean_na_fvalues = self.na_fvalues
|
2437 | 2437 |
|
| 2438 | + try: |
| 2439 | + if isinstance(clean_dtypes, dict): |
| 2440 | + for col, dtype in clean_dtypes.items(): |
| 2441 | + if is_bool_dtype(dtype) and data[col][data[col] == ''].size: |
| 2442 | + raise ValueError("Bool column has NA values in " |
| 2443 | + "column {column}".format(column=col)) |
| 2444 | + elif isinstance(clean_dtypes, string_types): |
| 2445 | + for col, values in data.items(): |
| 2446 | + if any(isna(values)): |
| 2447 | + raise ValueError("Bool column has NA values in " |
| 2448 | + "column {column}".format(column=col)) |
| 2449 | + except (AttributeError, TypeError): # invalid input to is_bool_dtype |
| 2450 | + pass |
| 2451 | + |
2438 | 2452 | return self._convert_to_ndarrays(data, clean_na_values,
|
2439 | 2453 | clean_na_fvalues, self.verbose,
|
2440 | 2454 | clean_conv, clean_dtypes)
|
|
0 commit comments