Skip to content

[Python] Fix deprecation warnings in the tests with numpy/pandas nightly #51301

Description

@jorisvandenbossche

Some of the warnings I am seeing (from https://github.com/ursacomputing/crossbow/actions/runs/34548523730/job/103106277981):

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_array.py::test_array_from_timestamp_with_generic_unit
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_array.py:2682: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`). Please use a specific unit instead.
    n = np.datetime64('NaT')

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_array.py::test_array_from_numpy_timedelta_incorrect_unit
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_array.py:2723: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. This includes implicit conversion of bare integers (e.g. `+ 1`). Please use a specific unit instead.
    td = np.timedelta64(1)

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:2648: Pandas4Warning: DatetimeIndex.dayofweek is deprecated and will be removed in a future version. Use DatetimeIndex.day_of_week instead.
    dayofweek = ts.dt.dayofweek.astype("int64")

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_extract_datetime_components
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:2649: Pandas4Warning: DatetimeIndex.dayofyear is deprecated and will be removed in a future version. Use DatetimeIndex.day_of_year instead.
    dayofyear = ts.dt.dayofyear.astype("int64")

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[nanosecond]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[microsecond]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[millisecond]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[second]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[minute]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[hour]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py::test_round_temporal[day]
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_compute.py:2972: UserWarning: The 'unit' keyword is only used when the Timestamp input is an integer or float, not str. To specify the storage unit of the output use `ts.as_unit(unit)`
    ts = pd.Series([pd.Timestamp(x, unit="ns") for x in timestamps])

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dataset.py::test_make_fragment
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dataset.py:243: Pandas4Warning: DatetimeIndex.dayofweek is deprecated and will be removed in a future version. Use DatetimeIndex.day_of_week instead.
    for part, chunk in df_b.groupby([df_b.date.dt.dayofweek, df_b.color]):

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_legacy_capsule_immutable_tensor[None]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_legacy_capsule_immutable_tensor[max_version1]
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py:78: DeprecationWarning: Exporting an unversioned DLPack capsule is deprecated, pass max_version=(1, 0) or higher.
    return f(*args, **kwargs)

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_versioned_roundtrip[array]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_versioned_roundtrip[sliced_array]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_versioned_roundtrip[empty_array]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_versioned_roundtrip[tensor]
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py:310: DeprecationWarning: Exporting an unversioned DLPack capsule is deprecated, pass max_version=(1, 0) or higher.
    expected = np.from_dlpack(DLPackForwarder(obj, max_version=None))

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_dlpack.py::test_dlpack_not_supported
  /opt/conda/envs/arrow/lib/python3.14/site-packages/_pytest/python.py:167: DeprecationWarning: Exporting an unversioned DLPack capsule is deprecated, pass max_version=(1, 0) or higher.
    result = testfunction(**testargs)

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_pandas.py::TestConvertMetadata::test_column_index_names_datetime[None]
opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_pandas.py::TestConvertMetadata::test_column_index_names_datetime[Europe/Brussels]
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_pandas.py:126: Pandas4Warning: assert_index_equal will check the 'freq' attribute by default in a future version; these freqs None and <50 * Days> do not match. Pass check_freq=True or check_freq=False to silence this warning
    tm.assert_frame_equal(result, expected, check_dtype=check_dtype,

opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_pandas.py::test_does_not_mutate_timedelta_dtype
  /opt/conda/envs/arrow/lib/python3.14/site-packages/pyarrow/tests/test_pandas.py:5009: DeprecationWarning: The 'generic' unit for NumPy timedelta is deprecated, and will raise an error in the future. Please use a specific unit instead.
    df = pd.DataFrame({"a": [np.timedelta64()]})

There are some other warnings related to "Series.values returning an ndarray that drops timezone information for DatetimeTZDtype is deprecated ..." (and similar), but that actually requires a code change and not just a test update, so will open a separate issue for that (-> #51302).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions