Skip to content

Commit

Permalink
BUG: astype(errors=ignore) for EAs (#56350)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored Dec 6, 2023
1 parent f2b3795 commit b64d87b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v2.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ Numeric
Conversion
^^^^^^^^^^
- Bug in :meth:`DataFrame.astype` when called with ``str`` on unpickled array - the array might change in-place (:issue:`54654`)
- Bug in :meth:`DataFrame.astype` where ``errors="ignore"`` had no effect for extension types (:issue:`54654`)
- Bug in :meth:`Series.convert_dtypes` not converting all NA column to ``null[pyarrow]`` (:issue:`55346`)
-

Expand Down
4 changes: 3 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -6659,7 +6659,9 @@ def astype(
return self.copy(deep=copy)
# GH 18099/22869: columnwise conversion to extension dtype
# GH 24704: self.items handles duplicate column names
results = [ser.astype(dtype, copy=copy) for _, ser in self.items()]
results = [
ser.astype(dtype, copy=copy, errors=errors) for _, ser in self.items()
]

else:
# else, only a single dtype is given
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,13 @@ def test_astype_float_from_non_pyarrow_str():
tm.assert_series_equal(result, expected)


def test_astype_errors_ignore():
# GH 55399
expected = pd.DataFrame({"col": [17000000]}, dtype="int32[pyarrow]")
result = expected.astype("float[pyarrow]", errors="ignore")
tm.assert_frame_equal(result, expected)


def test_to_numpy_with_defaults(data):
# GH49973
result = data.to_numpy()
Expand Down

0 comments on commit b64d87b

Please sign in to comment.