Skip to content

Commit d709713

Browse files
mroeschkepull[bot]
authored andcommitted
BUG: astype(errors=ignore) for EAs (#56350)
1 parent 0c4abfc commit d709713

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

doc/source/whatsnew/v2.2.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ Numeric
557557
Conversion
558558
^^^^^^^^^^
559559
- Bug in :meth:`DataFrame.astype` when called with ``str`` on unpickled array - the array might change in-place (:issue:`54654`)
560+
- Bug in :meth:`DataFrame.astype` where ``errors="ignore"`` had no effect for extension types (:issue:`54654`)
560561
- Bug in :meth:`Series.convert_dtypes` not converting all NA column to ``null[pyarrow]`` (:issue:`55346`)
561562
-
562563

pandas/core/generic.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -6659,7 +6659,9 @@ def astype(
66596659
return self.copy(deep=copy)
66606660
# GH 18099/22869: columnwise conversion to extension dtype
66616661
# GH 24704: self.items handles duplicate column names
6662-
results = [ser.astype(dtype, copy=copy) for _, ser in self.items()]
6662+
results = [
6663+
ser.astype(dtype, copy=copy, errors=errors) for _, ser in self.items()
6664+
]
66636665

66646666
else:
66656667
# else, only a single dtype is given

pandas/tests/extension/test_arrow.py

+7
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,13 @@ def test_astype_float_from_non_pyarrow_str():
14751475
tm.assert_series_equal(result, expected)
14761476

14771477

1478+
def test_astype_errors_ignore():
1479+
# GH 55399
1480+
expected = pd.DataFrame({"col": [17000000]}, dtype="int32[pyarrow]")
1481+
result = expected.astype("float[pyarrow]", errors="ignore")
1482+
tm.assert_frame_equal(result, expected)
1483+
1484+
14781485
def test_to_numpy_with_defaults(data):
14791486
# GH49973
14801487
result = data.to_numpy()

0 commit comments

Comments
 (0)