Skip to content

Commit ffdc947

Browse files
committed
Fixed errors='ignore' being ignored
Signed-off-by: nbonnin <[email protected]>
1 parent adca461 commit ffdc947

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pandas/core/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -5576,7 +5576,7 @@ def astype(self, dtype, copy: bool_t = True, errors: str = "raise"):
55765576
"""
55775577
if is_dict_like(dtype):
55785578
if self.ndim == 1: # i.e. Series
5579-
if len(dtype) > 1 or self.name not in dtype:
5579+
if len(dtype) > 1 or self.name not in dtype and errors == "raise":
55805580
raise KeyError(
55815581
"Only the Series name can be used for "
55825582
"the key in Series dtype mappings."
@@ -5585,7 +5585,7 @@ def astype(self, dtype, copy: bool_t = True, errors: str = "raise"):
55855585
return self.astype(new_type, copy, errors)
55865586

55875587
for col_name in dtype.keys():
5588-
if col_name not in self:
5588+
if col_name not in self and errors == "raise":
55895589
raise KeyError(
55905590
"Only a column name can be used for the "
55915591
"key in a dtype mappings argument."

0 commit comments

Comments
 (0)