Skip to content

Commit c35c7c2

Browse files
committed
Merge branch 'ea-astype-dispatch' into ea-sparse-2
2 parents a72ee1a + f147635 commit c35c7c2

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

pandas/core/dtypes/cast.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -653,10 +653,6 @@ def astype_nansafe(arr, dtype, copy=True):
653653
----------
654654
arr : ndarray
655655
dtype : np.dtype
656-
copy : bool or None, default True
657-
Whether to copy during the `.astype` (True) or
658-
just return a view (False). Passing `copy=None` will
659-
attempt to return a view, but will copy if necessary.
660656
"""
661657

662658
# dispatch on extension dtype if needed
@@ -745,15 +741,7 @@ def astype_nansafe(arr, dtype, copy=True):
745741

746742
if copy:
747743
return arr.astype(dtype, copy=True)
748-
else:
749-
try:
750-
return arr.view(dtype)
751-
except TypeError:
752-
if copy is None:
753-
# allowed to copy if necessary (e.g. object)
754-
return arr.astype(dtype, copy=True)
755-
else:
756-
raise
744+
return arr.view(dtype)
757745

758746

759747
def maybe_convert_objects(values, convert_dates=True, convert_numeric=True,

0 commit comments

Comments
 (0)