diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 5888600d2fa8e..a75536e46e60d 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -283,7 +283,8 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False): @classmethod def _simple_new(cls, values, freq=None, dtype=_NS_DTYPE): assert isinstance(values, np.ndarray) - if values.dtype == "i8": + if values.dtype != _NS_DTYPE: + assert values.dtype == "i8" values = values.view(_NS_DTYPE) result = object.__new__(cls) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 934c4c6e92bbe..adfb553d40ff0 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3504,6 +3504,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries: Slicing with this method is *always* positional. """ + assert isinstance(slobj, slice), type(slobj) axis = self._get_block_manager_axis(axis) result = self._constructor(self._data.get_slice(slobj, axis=axis)) result = result.__finalize__(self) diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index 3dc7dd7d81530..37a4b43648bb1 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -1316,7 +1316,6 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None): return blocks def _make_na_block(self, placement, fill_value=None): - # TODO: infer dtypes other than float64 from fill_value if fill_value is None: fill_value = np.nan diff --git a/pandas/core/ops/array_ops.py b/pandas/core/ops/array_ops.py index 5d53856729d0c..37a4a6eddaebe 100644 --- a/pandas/core/ops/array_ops.py +++ b/pandas/core/ops/array_ops.py @@ -43,9 +43,9 @@ def comp_method_OBJECT_ARRAY(op, x, y): if isinstance(y, list): y = construct_1d_object_array_from_listlike(y) - # TODO: Should the checks below be ABCIndexClass? if isinstance(y, (np.ndarray, ABCSeries, ABCIndex)): - # TODO: should this be ABCIndexClass?? + # Note: these checks can be for ABCIndex and not ABCIndexClass + # because that is the only object-dtype class. if not is_object_dtype(y.dtype): y = y.astype(np.object_) diff --git a/pandas/core/series.py b/pandas/core/series.py index 24e794014a15f..8577a7fb904dc 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4378,7 +4378,7 @@ def between(self, left, right, inclusive=True) -> "Series": # Convert to types that support pd.NA def _convert_dtypes( - self: ABCSeries, + self, infer_objects: bool = True, convert_string: bool = True, convert_integer: bool = True, diff --git a/pandas/tests/indexing/test_chaining_and_caching.py b/pandas/tests/indexing/test_chaining_and_caching.py index e845487ffca9a..17722e949df1e 100644 --- a/pandas/tests/indexing/test_chaining_and_caching.py +++ b/pandas/tests/indexing/test_chaining_and_caching.py @@ -346,20 +346,17 @@ def test_chained_getitem_with_lists(self): # GH6394 # Regression in chained getitem indexing with embedded list-like from # 0.12 - def check(result, expected): - tm.assert_numpy_array_equal(result, expected) - assert isinstance(result, np.ndarray) df = DataFrame({"A": 5 * [np.zeros(3)], "B": 5 * [np.ones(3)]}) expected = df["A"].iloc[2] result = df.loc[2, "A"] - check(result, expected) + tm.assert_numpy_array_equal(result, expected) result2 = df.iloc[2]["A"] - check(result2, expected) + tm.assert_numpy_array_equal(result2, expected) result3 = df["A"].loc[2] - check(result3, expected) + tm.assert_numpy_array_equal(result3, expected) result4 = df["A"].iloc[2] - check(result4, expected) + tm.assert_numpy_array_equal(result4, expected) def test_cache_updating(self): # GH 4939, make sure to update the cache on setitem