|
33 | 33 | from pandas.util._decorators import Appender, Substitution, rewrite_axis_style_signature
|
34 | 34 | from pandas.util._validators import validate_bool_kwarg, validate_fillna_kwargs
|
35 | 35 |
|
36 |
| -from pandas.core.dtypes.cast import maybe_promote, maybe_upcast_putmask |
37 | 36 | from pandas.core.dtypes.common import (
|
38 | 37 | ensure_int64,
|
39 | 38 | ensure_object,
|
@@ -968,15 +967,12 @@ def squeeze(self, axis=None):
|
968 | 967 | 1
|
969 | 968 | """
|
970 | 969 | axis = self._AXIS_NAMES if axis is None else (self._get_axis_number(axis),)
|
971 |
| - try: |
972 |
| - return self.iloc[ |
973 |
| - tuple( |
974 |
| - 0 if i in axis and len(a) == 1 else slice(None) |
975 |
| - for i, a in enumerate(self.axes) |
976 |
| - ) |
977 |
| - ] |
978 |
| - except Exception: |
979 |
| - return self |
| 970 | + return self.iloc[ |
| 971 | + tuple( |
| 972 | + 0 if i in axis and len(a) == 1 else slice(None) |
| 973 | + for i, a in enumerate(self.axes) |
| 974 | + ) |
| 975 | + ] |
980 | 976 |
|
981 | 977 | def swaplevel(self, i=-2, j=-1, axis=0):
|
982 | 978 | """
|
@@ -9053,22 +9049,9 @@ def _where(
|
9053 | 9049 | # try to not change dtype at first (if try_quick)
|
9054 | 9050 | if try_quick:
|
9055 | 9051 |
|
9056 |
| - try: |
9057 |
| - new_other = com.values_from_object(self) |
9058 |
| - new_other = new_other.copy() |
9059 |
| - new_other[icond] = other |
9060 |
| - other = new_other |
9061 |
| - except Exception: |
9062 |
| - try_quick = False |
9063 |
| - |
9064 |
| - # let's create a new (if we failed at the above |
9065 |
| - # or not try_quick |
9066 |
| - if not try_quick: |
9067 |
| - |
9068 |
| - dtype, fill_value = maybe_promote(other.dtype) |
9069 |
| - new_other = np.empty(len(icond), dtype=dtype) |
9070 |
| - new_other.fill(fill_value) |
9071 |
| - maybe_upcast_putmask(new_other, icond, other) |
| 9052 | + new_other = com.values_from_object(self) |
| 9053 | + new_other = new_other.copy() |
| 9054 | + new_other[icond] = other |
9072 | 9055 | other = new_other
|
9073 | 9056 |
|
9074 | 9057 | else:
|
|
0 commit comments