From 1ed3c25a8998c8c5a76e34b0827e718e9b440bd6 Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Mon, 21 Sep 2026 10:38:41 +0200 Subject: [PATCH 1/9] Fix for deprecated generic units --- python/pyarrow/tests/test_array.py | 13 +++++++++---- python/pyarrow/tests/test_pandas.py | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/python/pyarrow/tests/test_array.py b/python/pyarrow/tests/test_array.py index a1e3616c9cea..7bb855664b82 100644 --- a/python/pyarrow/tests/test_array.py +++ b/python/pyarrow/tests/test_array.py @@ -35,6 +35,7 @@ import pyarrow as pa import pyarrow.tests.strategies as past import pyarrow.compute as pc +from pyarrow.vendored.version import Version @pytest.mark.processes @@ -2679,6 +2680,8 @@ def test_array_from_list_of_timestamps(unit): @pytest.mark.numpy def test_array_from_timestamp_with_generic_unit(): + if Version(np.__version__) >= Version("2.5.0"): + pytest.skip("generic units of timedelta64 deprecated") n = np.datetime64('NaT') x = np.datetime64('2017-01-01 01:01:01.111111111') y = np.datetime64('2018-11-22 12:24:48.111111111') @@ -2720,11 +2723,13 @@ def test_array_from_numpy_timedelta(dtype, type): @pytest.mark.numpy def test_array_from_numpy_timedelta_incorrect_unit(): # generic (no unit) - td = np.timedelta64(1) + if Version(np.__version__) < Version("2.5.0"): + # Generic units of timedelta64 deprecated in NumPy 2.5 + td = np.timedelta64(1) - for data in [[td], np.array([td])]: - with pytest.raises(NotImplementedError): - pa.array(data) + for data in [[td], np.array([td])]: + with pytest.raises(NotImplementedError): + pa.array(data) # unsupported unit td = np.timedelta64(1, 'M') diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index dd20a0aa9777..374dc3b6253f 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -5006,7 +5006,7 @@ def test_does_not_mutate_timedelta_dtype(): assert np.dtype(np.timedelta64) == expected - df = pd.DataFrame({"a": [np.timedelta64()]}) + df = pd.DataFrame({"a": [np.timedelta64(0, "s")]}) t = pa.Table.from_pandas(df) t.to_pandas() From b2d348a97c6562489a2fbe18954ec50c5319c627 Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Mon, 21 Sep 2026 12:01:05 +0200 Subject: [PATCH 2/9] Fix dlpack warnings --- python/pyarrow/array.pxi | 2 +- python/pyarrow/tensor.pxi | 2 +- python/pyarrow/tests/test_compute.py | 3 ++- python/pyarrow/tests/test_dlpack.py | 14 ++++++++++---- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/python/pyarrow/array.pxi b/python/pyarrow/array.pxi index 3060c533255b..b3d866293505 100644 --- a/python/pyarrow/array.pxi +++ b/python/pyarrow/array.pxi @@ -2370,13 +2370,13 @@ cdef class Array(_PandasConvertible): raise BufferError( f"The copy argument is not supported with legacy (pre 1.0) DLPack version." ) + legacy_tensor = GetResultValue(ExportArrayToDLPack(self.sp_array)) # Note: from March 2025 onwards, it's okay to raise BufferError here. # Still we keep the V0 version as the V1 was only added in August 2026. warnings.warn( "Exporting an unversioned DLPack capsule is deprecated, " "pass max_version=(1, 0) or higher.", DeprecationWarning, stacklevel=2) - legacy_tensor = GetResultValue(ExportArrayToDLPack(self.sp_array)) return PyCapsule_New(legacy_tensor, 'dltensor', dlpack_pycapsule_deleter) # Currently no major version other than legacy 0 and current 1.3 diff --git a/python/pyarrow/tensor.pxi b/python/pyarrow/tensor.pxi index 7f006f294175..b41309d19a85 100644 --- a/python/pyarrow/tensor.pxi +++ b/python/pyarrow/tensor.pxi @@ -399,13 +399,13 @@ strides: {self.strides}""" raise BufferError( f"The copy argument is not supported with legacy (pre 1.0) DLPack version." ) + legacy_tensor = GetResultValue(ExportTensorToDLPack(self.sp_tensor)) # Note: from March 2025 onwards, it's okay to raise BufferError here. # Still we keep the V0 version as the V1 was only added in August 2026. warnings.warn( "Exporting an unversioned DLPack capsule is deprecated, " "pass max_version=(1, 0) or higher.", DeprecationWarning, stacklevel=2) - legacy_tensor = GetResultValue(ExportTensorToDLPack(self.sp_tensor)) return PyCapsule_New(legacy_tensor, 'dltensor', dlpack_pycapsule_deleter) # Currently no major version other than legacy 0 and current 1.3 diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index 797fbc220ec3..cd45295b221f 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -138,7 +138,8 @@ def test_exported_option_classes(): @pytest.mark.filterwarnings( - "ignore:pyarrow.CumulativeSumOptions is deprecated as of 14.0" + "ignore:pyarrow.CumulativeSumOptions is deprecated as of 14.0", + "ignore:null_placement in RankOptions is deprecated as of 25.0.0" ) def test_option_class_equality(request): options = [ diff --git a/python/pyarrow/tests/test_dlpack.py b/python/pyarrow/tests/test_dlpack.py index 0c3c082fd6ed..bf93c431feca 100644 --- a/python/pyarrow/tests/test_dlpack.py +++ b/python/pyarrow/tests/test_dlpack.py @@ -267,6 +267,9 @@ def immutable_tensor(): @check_bytes_allocated +@pytest.mark.filterwarnings( + "ignore:Exporting an unversioned DLPack capsule is deprecated" +) @pytest.mark.parametrize('max_version', [None, (0, 8)]) def test_dlpack_legacy_capsule_immutable_tensor(max_version): tensor = immutable_tensor() @@ -305,6 +308,9 @@ def test_dlpack_versioned_capsule(obj, max_version, copy): @requires_numpy_version("2.1.0") @check_bytes_allocated +@pytest.mark.filterwarnings( + "ignore:Exporting an unversioned DLPack capsule is deprecated" +) @pytest.mark.parametrize('obj', dlpack_objects()) def test_dlpack_versioned_roundtrip(obj): expected = np.from_dlpack(DLPackForwarder(obj, max_version=None)) @@ -335,24 +341,24 @@ def test_dlpack_not_supported(): arr = pa.array([1, None, 3]) with pytest.raises(TypeError, match="Can only use DLPack " "on arrays with no nulls."): - np.from_dlpack(arr) + np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) arr = pa.array( [[0, 1], [3, 4]], type=pa.list_(pa.int32()) ) with pytest.raises(TypeError, match="DataType is not compatible with DLPack spec"): - np.from_dlpack(arr) + np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) arr = pa.array([]) with pytest.raises(TypeError, match="DataType is not compatible with DLPack spec"): - np.from_dlpack(arr) + np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) # DLPack doesn't support bit-packed boolean values arr = pa.array([True, False, True]) with pytest.raises(TypeError, match="Bit-packed boolean data type " "not supported by DLPack."): - np.from_dlpack(arr) + np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) def test_dlpack_cuda_not_supported(): From 180c88109caa84788491041e22e66775d576f89d Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Mon, 21 Sep 2026 12:14:08 +0200 Subject: [PATCH 3/9] Fix null_placement warnings --- python/pyarrow/tests/test_compute.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index cd45295b221f..bd4ab34e1c62 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -139,7 +139,7 @@ def test_exported_option_classes(): @pytest.mark.filterwarnings( "ignore:pyarrow.CumulativeSumOptions is deprecated as of 14.0", - "ignore:null_placement in RankOptions is deprecated as of 25.0.0" + "ignore:Specifying null_placement in RankOptions" ) def test_option_class_equality(request): options = [ @@ -2945,6 +2945,9 @@ def _check_temporal_rounding(ts, values, unit): @pytest.mark.parametrize('unit', ("nanosecond", "microsecond", "millisecond", "second", "minute", "hour", "day")) @pytest.mark.pandas +@pytest.mark.filterwarnings( + "ignore:Specifying null_placement in RankOptions" +) def test_round_temporal(unit): values = (1, 2, 3, 4, 5, 6, 7, 10, 15, 24, 60, 250, 500, 750) timestamps = [ @@ -3963,6 +3966,9 @@ def test_random(): pc.random(100, initializer=[]) +@pytest.mark.filterwarnings( + "ignore:Specifying null_placement in RankOptions" +) @pytest.mark.parametrize( "tiebreaker,expected_values", [("min", [3, 1, 4, 6, 4, 6, 1]), @@ -3979,6 +3985,9 @@ def test_rank_options_tiebreaker(tiebreaker, expected_values): assert result.equals(expected) +@pytest.mark.filterwarnings( + "ignore:Specifying null_placement in RankOptions" +) def test_rank_options(): arr = pa.array([1.2, 0.0, 5.3, None, 5.3, None, 0.0]) expected = pa.array([3, 1, 4, 6, 5, 7, 2], type=pa.uint64()) @@ -4011,6 +4020,9 @@ def test_rank_options(): tiebreaker="NonExisting") +@pytest.mark.filterwarnings( + "ignore:Specifying null_placement in RankOptions" +) def test_rank_quantile_options(): arr = pa.array([None, 1, None, 2, None]) expected = pa.array([0.7, 0.1, 0.7, 0.3, 0.7], type=pa.float64()) @@ -4041,6 +4053,9 @@ def test_rank_quantile_options(): pc.rank_quantile(arr, sort_keys="XXX") +@pytest.mark.filterwarnings( + "ignore:Specifying null_placement in RankOptions" +) def test_rank_normal_options(): arr = pa.array([None, 1, None, 2, None]) From 43de55df8fa4b9f9bafb003eb8c69173524c8398 Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Mon, 21 Sep 2026 12:20:10 +0200 Subject: [PATCH 4/9] Fix unit keyward warning in pd.timestamp --- python/pyarrow/tests/test_compute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index bd4ab34e1c62..c284bcb09d00 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -2972,7 +2972,7 @@ def test_round_temporal(unit): if sys.platform == "win32": timestamps = timestamps[:3] + timestamps[5:] - ts = pd.Series([pd.Timestamp(x, unit="ns") for x in timestamps]) + ts = pd.Series([pd.Timestamp(x).as_unit("ns") for x in timestamps]) _check_temporal_rounding(ts, values, unit) timezones = ["Asia/Kolkata", "America/New_York", "Etc/GMT-4", "Etc/GMT+4", From 0baa2422b6175cbbf18cda6bc5950f0bdee5c50e Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Tue, 22 Sep 2026 10:44:02 +0200 Subject: [PATCH 5/9] Revert "Fix null_placement warnings" This reverts commit 180c88109caa84788491041e22e66775d576f89d. --- python/pyarrow/tests/test_compute.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index c284bcb09d00..11081e79bfa8 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -138,8 +138,7 @@ def test_exported_option_classes(): @pytest.mark.filterwarnings( - "ignore:pyarrow.CumulativeSumOptions is deprecated as of 14.0", - "ignore:Specifying null_placement in RankOptions" + "ignore:pyarrow.CumulativeSumOptions is deprecated as of 14.0" ) def test_option_class_equality(request): options = [ @@ -2945,9 +2944,6 @@ def _check_temporal_rounding(ts, values, unit): @pytest.mark.parametrize('unit', ("nanosecond", "microsecond", "millisecond", "second", "minute", "hour", "day")) @pytest.mark.pandas -@pytest.mark.filterwarnings( - "ignore:Specifying null_placement in RankOptions" -) def test_round_temporal(unit): values = (1, 2, 3, 4, 5, 6, 7, 10, 15, 24, 60, 250, 500, 750) timestamps = [ @@ -3966,9 +3962,6 @@ def test_random(): pc.random(100, initializer=[]) -@pytest.mark.filterwarnings( - "ignore:Specifying null_placement in RankOptions" -) @pytest.mark.parametrize( "tiebreaker,expected_values", [("min", [3, 1, 4, 6, 4, 6, 1]), @@ -3985,9 +3978,6 @@ def test_rank_options_tiebreaker(tiebreaker, expected_values): assert result.equals(expected) -@pytest.mark.filterwarnings( - "ignore:Specifying null_placement in RankOptions" -) def test_rank_options(): arr = pa.array([1.2, 0.0, 5.3, None, 5.3, None, 0.0]) expected = pa.array([3, 1, 4, 6, 5, 7, 2], type=pa.uint64()) @@ -4020,9 +4010,6 @@ def test_rank_options(): tiebreaker="NonExisting") -@pytest.mark.filterwarnings( - "ignore:Specifying null_placement in RankOptions" -) def test_rank_quantile_options(): arr = pa.array([None, 1, None, 2, None]) expected = pa.array([0.7, 0.1, 0.7, 0.3, 0.7], type=pa.float64()) @@ -4053,9 +4040,6 @@ def test_rank_quantile_options(): pc.rank_quantile(arr, sort_keys="XXX") -@pytest.mark.filterwarnings( - "ignore:Specifying null_placement in RankOptions" -) def test_rank_normal_options(): arr = pa.array([None, 1, None, 2, None]) From 84a85181848b78279047e93c44955acd0eda364f Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Tue, 22 Sep 2026 14:38:33 +0200 Subject: [PATCH 6/9] Revert the change on __dlpack__ --- python/pyarrow/array.pxi | 2 +- python/pyarrow/tensor.pxi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pyarrow/array.pxi b/python/pyarrow/array.pxi index b3d866293505..3060c533255b 100644 --- a/python/pyarrow/array.pxi +++ b/python/pyarrow/array.pxi @@ -2370,13 +2370,13 @@ cdef class Array(_PandasConvertible): raise BufferError( f"The copy argument is not supported with legacy (pre 1.0) DLPack version." ) - legacy_tensor = GetResultValue(ExportArrayToDLPack(self.sp_array)) # Note: from March 2025 onwards, it's okay to raise BufferError here. # Still we keep the V0 version as the V1 was only added in August 2026. warnings.warn( "Exporting an unversioned DLPack capsule is deprecated, " "pass max_version=(1, 0) or higher.", DeprecationWarning, stacklevel=2) + legacy_tensor = GetResultValue(ExportArrayToDLPack(self.sp_array)) return PyCapsule_New(legacy_tensor, 'dltensor', dlpack_pycapsule_deleter) # Currently no major version other than legacy 0 and current 1.3 diff --git a/python/pyarrow/tensor.pxi b/python/pyarrow/tensor.pxi index b41309d19a85..7f006f294175 100644 --- a/python/pyarrow/tensor.pxi +++ b/python/pyarrow/tensor.pxi @@ -399,13 +399,13 @@ strides: {self.strides}""" raise BufferError( f"The copy argument is not supported with legacy (pre 1.0) DLPack version." ) - legacy_tensor = GetResultValue(ExportTensorToDLPack(self.sp_tensor)) # Note: from March 2025 onwards, it's okay to raise BufferError here. # Still we keep the V0 version as the V1 was only added in August 2026. warnings.warn( "Exporting an unversioned DLPack capsule is deprecated, " "pass max_version=(1, 0) or higher.", DeprecationWarning, stacklevel=2) + legacy_tensor = GetResultValue(ExportTensorToDLPack(self.sp_tensor)) return PyCapsule_New(legacy_tensor, 'dltensor', dlpack_pycapsule_deleter) # Currently no major version other than legacy 0 and current 1.3 From 54feb6dae6d5bb6a701fc6c97218de2d43fa7438 Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Thu, 24 Sep 2026 08:04:40 +0200 Subject: [PATCH 7/9] Revert all dplack related changes --- python/pyarrow/tests/test_dlpack.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/python/pyarrow/tests/test_dlpack.py b/python/pyarrow/tests/test_dlpack.py index bf93c431feca..0c3c082fd6ed 100644 --- a/python/pyarrow/tests/test_dlpack.py +++ b/python/pyarrow/tests/test_dlpack.py @@ -267,9 +267,6 @@ def immutable_tensor(): @check_bytes_allocated -@pytest.mark.filterwarnings( - "ignore:Exporting an unversioned DLPack capsule is deprecated" -) @pytest.mark.parametrize('max_version', [None, (0, 8)]) def test_dlpack_legacy_capsule_immutable_tensor(max_version): tensor = immutable_tensor() @@ -308,9 +305,6 @@ def test_dlpack_versioned_capsule(obj, max_version, copy): @requires_numpy_version("2.1.0") @check_bytes_allocated -@pytest.mark.filterwarnings( - "ignore:Exporting an unversioned DLPack capsule is deprecated" -) @pytest.mark.parametrize('obj', dlpack_objects()) def test_dlpack_versioned_roundtrip(obj): expected = np.from_dlpack(DLPackForwarder(obj, max_version=None)) @@ -341,24 +335,24 @@ def test_dlpack_not_supported(): arr = pa.array([1, None, 3]) with pytest.raises(TypeError, match="Can only use DLPack " "on arrays with no nulls."): - np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) + np.from_dlpack(arr) arr = pa.array( [[0, 1], [3, 4]], type=pa.list_(pa.int32()) ) with pytest.raises(TypeError, match="DataType is not compatible with DLPack spec"): - np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) + np.from_dlpack(arr) arr = pa.array([]) with pytest.raises(TypeError, match="DataType is not compatible with DLPack spec"): - np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) + np.from_dlpack(arr) # DLPack doesn't support bit-packed boolean values arr = pa.array([True, False, True]) with pytest.raises(TypeError, match="Bit-packed boolean data type " "not supported by DLPack."): - np.from_dlpack(DLPackForwarder(arr, max_version=(1, 0))) + np.from_dlpack(arr) def test_dlpack_cuda_not_supported(): From a148c139ca6d8d498c06ecd9f6d0aa0d78da48a2 Mon Sep 17 00:00:00 2001 From: AlenkaF Date: Thu, 24 Sep 2026 08:25:23 +0200 Subject: [PATCH 8/9] Update test_does_not_mutate_timedelta_dtype --- python/pyarrow/tests/test_pandas.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index 374dc3b6253f..6e47b68bcc4a 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -5002,15 +5002,15 @@ def test_threaded_pandas_import(): def test_does_not_mutate_timedelta_dtype(): - expected = np.dtype('m8') + expected = np.dtype(' Date: Thu, 24 Sep 2026 12:28:36 +0200 Subject: [PATCH 9/9] Add missing deprecation fixes --- python/pyarrow/tests/test_compute.py | 6 ++++-- python/pyarrow/tests/test_dataset.py | 2 +- python/pyarrow/tests/test_pandas.py | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index 11081e79bfa8..96da6ca0e6a8 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -2644,8 +2644,8 @@ def _check_datetime_components(timestamps, timezone=None): year = ts.dt.year.astype("int64") month = ts.dt.month.astype("int64") day = ts.dt.day.astype("int64") - dayofweek = ts.dt.dayofweek.astype("int64") - dayofyear = ts.dt.dayofyear.astype("int64") + dayofweek = pd.DatetimeIndex(ts).day_of_week.astype("int64") + dayofyear = pd.DatetimeIndex(ts).day_of_year.astype("int64") quarter = ts.dt.quarter.astype("int64") hour = ts.dt.hour.astype("int64") minute = ts.dt.minute.astype("int64") @@ -2657,7 +2657,9 @@ def _check_datetime_components(timestamps, timezone=None): assert pc.is_leap_year(tsa).equals(pa.array(ts.dt.is_leap_year)) assert pc.month(tsa).equals(pa.array(month)) assert pc.day(tsa).equals(pa.array(day)) + assert pc.day_of_week(tsa).equals(pa.array(dayofweek)) + assert pc.day_of_year(tsa).equals(pa.array(dayofyear)) assert pc.iso_year(tsa).equals(pa.array(iso_year)) assert pc.iso_week(tsa).equals(pa.array(iso_week)) diff --git a/python/pyarrow/tests/test_dataset.py b/python/pyarrow/tests/test_dataset.py index 0a94c0bd9875..086550d2c74a 100644 --- a/python/pyarrow/tests/test_dataset.py +++ b/python/pyarrow/tests/test_dataset.py @@ -240,7 +240,7 @@ def multisourcefs(request): # create one with schema partitioning by weekday and color mockfs.create_dir('schema') - for part, chunk in df_b.groupby([df_b.date.dt.dayofweek, df_b.color]): + for part, chunk in df_b.groupby([pd.DatetimeIndex(df_b.date).day_of_week, df_b.color]): folder = f'schema/{part[0]}/{part[1]}' path = f'{folder}/chunk.parquet' mockfs.create_dir(folder) diff --git a/python/pyarrow/tests/test_pandas.py b/python/pyarrow/tests/test_pandas.py index 6e47b68bcc4a..8b70bafa1652 100644 --- a/python/pyarrow/tests/test_pandas.py +++ b/python/pyarrow/tests/test_pandas.py @@ -99,8 +99,8 @@ def _alltypes_example(size=100): def _check_pandas_roundtrip(df, expected=None, use_threads=False, expected_schema=None, - check_dtype=True, schema=None, - preserve_index=False, + check_dtype=True, check_freq=False, + schema=None,preserve_index=False, as_batch=False): klass = pa.RecordBatch if as_batch else pa.Table table = klass.from_pandas(df, schema=schema, @@ -125,7 +125,8 @@ def _check_pandas_roundtrip(df, expected=None, use_threads=False, "ignore", "elementwise comparison failed", DeprecationWarning) tm.assert_frame_equal(result, expected, check_dtype=check_dtype, check_index_type=('equiv' if preserve_index - else False)) + else False), + check_freq=check_freq) def _check_series_roundtrip(s, type_=None, expected_pa_type=None):