Skip to content

Commit 5919f9d

Browse files
jbrockmendeljreback
authored andcommitted
remove undesired values kwarg (#27625)
1 parent 854a89d commit 5919f9d

File tree

1 file changed

+30
-33
lines changed

1 file changed

+30
-33
lines changed

pandas/core/internals/blocks.py

+30-33
Original file line numberDiff line numberDiff line change
@@ -552,10 +552,10 @@ def f(m, v, i):
552552

553553
return self.split_and_operate(None, f, False)
554554

555-
def astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
556-
return self._astype(dtype, copy=copy, errors=errors, values=values, **kwargs)
555+
def astype(self, dtype, copy=False, errors="raise", **kwargs):
556+
return self._astype(dtype, copy=copy, errors=errors, **kwargs)
557557

558-
def _astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
558+
def _astype(self, dtype, copy=False, errors="raise", **kwargs):
559559
"""Coerce to the new type
560560
561561
Parameters
@@ -616,42 +616,39 @@ def _astype(self, dtype, copy=False, errors="raise", values=None, **kwargs):
616616
return self.copy()
617617
return self
618618

619-
if values is None:
620-
try:
621-
# force the copy here
622-
if self.is_extension:
623-
values = self.values.astype(dtype)
624-
else:
625-
if issubclass(dtype.type, str):
626-
627-
# use native type formatting for datetime/tz/timedelta
628-
if self.is_datelike:
629-
values = self.to_native_types()
619+
try:
620+
# force the copy here
621+
if self.is_extension:
622+
values = self.values.astype(dtype)
623+
else:
624+
if issubclass(dtype.type, str):
630625

631-
# astype formatting
632-
else:
633-
values = self.get_values()
626+
# use native type formatting for datetime/tz/timedelta
627+
if self.is_datelike:
628+
values = self.to_native_types()
634629

630+
# astype formatting
635631
else:
636-
values = self.get_values(dtype=dtype)
632+
values = self.get_values()
637633

638-
# _astype_nansafe works fine with 1-d only
639-
vals1d = values.ravel()
640-
values = astype_nansafe(vals1d, dtype, copy=True, **kwargs)
634+
else:
635+
values = self.get_values(dtype=dtype)
641636

642-
# TODO(extension)
643-
# should we make this attribute?
644-
if isinstance(values, np.ndarray):
645-
values = values.reshape(self.shape)
637+
# _astype_nansafe works fine with 1-d only
638+
vals1d = values.ravel()
639+
values = astype_nansafe(vals1d, dtype, copy=True, **kwargs)
646640

647-
except Exception:
648-
# e.g. astype_nansafe can fail on object-dtype of strings
649-
# trying to convert to float
650-
if errors == "raise":
651-
raise
652-
newb = self.copy() if copy else self
653-
else:
654-
newb = make_block(values, placement=self.mgr_locs, ndim=self.ndim)
641+
# TODO(extension)
642+
# should we make this attribute?
643+
if isinstance(values, np.ndarray):
644+
values = values.reshape(self.shape)
645+
646+
except Exception:
647+
# e.g. astype_nansafe can fail on object-dtype of strings
648+
# trying to convert to float
649+
if errors == "raise":
650+
raise
651+
newb = self.copy() if copy else self
655652
else:
656653
newb = make_block(values, placement=self.mgr_locs, ndim=self.ndim)
657654

0 commit comments

Comments
 (0)