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_compute.py b/python/pyarrow/tests/test_compute.py index 797fbc220ec3..562b04ae4579 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 = ts.dt.day_of_week.astype("int64") + dayofyear = ts.dt.day_of_year.astype("int64") quarter = ts.dt.quarter.astype("int64") hour = ts.dt.hour.astype("int64") minute = ts.dt.minute.astype("int64") @@ -2968,7 +2968,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", diff --git a/python/pyarrow/tests/test_dataset.py b/python/pyarrow/tests/test_dataset.py index 0a94c0bd9875..9ddfdfdc9c49 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([df_b.date.dt.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 dd20a0aa9777..d08920cf02ff 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): @@ -5002,15 +5003,15 @@ def test_threaded_pandas_import(): def test_does_not_mutate_timedelta_dtype(): - expected = np.dtype('m8') + expected = np.dtype('