From ee46751c1b6323ae0ea1f8a182c45ccb53e72778 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Fri, 13 Dec 2024 11:42:46 -0500 Subject: [PATCH] feedback --- pandas/core/arrays/arrow/array.py | 4 +++- pandas/core/frame.py | 4 ---- pandas/core/internals/blocks.py | 2 -- pandas/tests/frame/methods/test_astype.py | 10 +++++++++- pandas/tests/frame/methods/test_combine_first.py | 2 +- pandas/tests/frame/methods/test_dtypes.py | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pandas/core/arrays/arrow/array.py b/pandas/core/arrays/arrow/array.py index afa219f611992..311de77799260 100644 --- a/pandas/core/arrays/arrow/array.py +++ b/pandas/core/arrays/arrow/array.py @@ -2160,7 +2160,9 @@ def interpolate( """ # NB: we return type(self) even if copy=False if not self.dtype._is_numeric: - raise ValueError("Values must be numeric.") + raise NotImplementedError( + f"interpolate is not implemented for dtype={self.dtype}" + ) if ( not pa_version_under13p0 diff --git a/pandas/core/frame.py b/pandas/core/frame.py index bef474b949094..34b448a0d8d1c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -6273,10 +6273,6 @@ class max type else: to_insert = ((self.index, None),) - if len(new_obj.columns) == 0 and names: - target_dtype = Index(names).dtype - new_obj.columns = new_obj.columns.astype(target_dtype) - multi_col = isinstance(self.columns, MultiIndex) for j, (lev, lab) in enumerate(to_insert, start=1): i = self.index.nlevels - j diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 639d5a410213f..e3f8eb5ff46fd 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -2361,6 +2361,4 @@ def external_values(values: ArrayLike) -> ArrayLike: values.flags.writeable = False # TODO(CoW) we should also mark our ExtensionArrays as read-only - if isinstance(values, ExtensionArray): - ... # this is why test_to_dict_of_blocks_item_cache fails return values diff --git a/pandas/tests/frame/methods/test_astype.py b/pandas/tests/frame/methods/test_astype.py index b3fe7460d2da9..76df4e28eb5a2 100644 --- a/pandas/tests/frame/methods/test_astype.py +++ b/pandas/tests/frame/methods/test_astype.py @@ -765,7 +765,15 @@ def test_astype_dt64_to_string( item = item.iloc[0] if using_infer_string: assert item is pd.NA - else: + + # Check that Series/DataFrame.astype matches DatetimeArray.astype + expected = frame_or_series(dta.astype("str")) + tm.assert_equal(result, expected) + + item = result.iloc[0] + if frame_or_series is DataFrame: + item = item.iloc[0] + if using_infer_string: assert item is np.nan def test_astype_td64_to_string(self, frame_or_series): diff --git a/pandas/tests/frame/methods/test_combine_first.py b/pandas/tests/frame/methods/test_combine_first.py index 210394e33bd3b..a70876b5a96ca 100644 --- a/pandas/tests/frame/methods/test_combine_first.py +++ b/pandas/tests/frame/methods/test_combine_first.py @@ -30,7 +30,7 @@ def test_combine_first_mixed(self): combined = f.combine_first(g) tm.assert_frame_equal(combined, exp) - def test_combine_first(self, float_frame, using_infer_string): + def test_combine_first(self, float_frame): # disjoint head, tail = float_frame[:5], float_frame[5:] diff --git a/pandas/tests/frame/methods/test_dtypes.py b/pandas/tests/frame/methods/test_dtypes.py index dd8afccf2e25c..bf01ec73cf72b 100644 --- a/pandas/tests/frame/methods/test_dtypes.py +++ b/pandas/tests/frame/methods/test_dtypes.py @@ -137,5 +137,5 @@ def test_frame_apply_np_array_return_type(self, using_infer_string): # GH 35517 df = DataFrame([["foo"]]) result = df.apply(lambda col: np.array("bar")) - expected = Series(np.array(["bar"]), dtype=object) + expected = Series(np.array("bar")) tm.assert_series_equal(result, expected)