Skip to content

API: dispatch to EA.astype #22343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Aug 20, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions pandas/core/dtypes/cast.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,6 @@ def astype_nansafe(arr, dtype, copy=True):
----------
arr : ndarray
dtype : np.dtype
copy : bool or None, default True
Whether to copy during the `.astype` (True) or
just return a view (False). Passing `copy=None` will
attempt to return a view, but will copy if necessary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the copy keyword still exists, so I would not remove it completely

"""

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

if copy:
return arr.astype(dtype, copy=True)
else:
try:
return arr.view(dtype)
except TypeError:
if copy is None:
# allowed to copy if necessary (e.g. object)
return arr.astype(dtype, copy=True)
else:
raise
return arr.view(dtype)


def maybe_convert_objects(values, convert_dates=True, convert_numeric=True,
Expand Down