From 4ed67ac9ef3d9fde6fb8441bc9ea33c0d786649e Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Thu, 22 Feb 2024 18:43:15 +0100 Subject: [PATCH] Remove PyArrow deprecation warning (#57556) * Revert "DEPS: Add warning if pyarrow is not installed (#56896)" This reverts commit 5c2a4075 * Add whatsnew * Update * Update doc/source/whatsnew/v2.2.1.rst Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --------- Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> --- .github/workflows/unit-tests.yml | 5 +---- doc/source/whatsnew/v2.2.1.rst | 10 ++++++++++ pandas/__init__.py | 32 -------------------------------- pandas/compat/pyarrow.py | 2 -- pandas/tests/test_common.py | 25 ------------------------- 5 files changed, 11 insertions(+), 63 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 533b81013a264..855973a22886a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -64,10 +64,7 @@ jobs: - name: "Numpy Dev" env_file: actions-311-numpydev.yaml pattern: "not slow and not network and not single_cpu" - # Currently restricted the warnings that error to Deprecation Warnings from numpy - # done since pyarrow isn't compatible with numpydev always - # TODO: work with pyarrow to revert this? - test_args: "-W error::DeprecationWarning:numpy -W error::FutureWarning:numpy" + test_args: "-W error::DeprecationWarning -W error::FutureWarning" - name: "Pyarrow Nightly" env_file: actions-311-pyarrownightly.yaml pattern: "not slow and not network and not single_cpu" diff --git a/doc/source/whatsnew/v2.2.1.rst b/doc/source/whatsnew/v2.2.1.rst index e381f9df16383..35d64c99f2002 100644 --- a/doc/source/whatsnew/v2.2.1.rst +++ b/doc/source/whatsnew/v2.2.1.rst @@ -67,6 +67,16 @@ Bug fixes Other ~~~~~ + +.. note:: + + The ``DeprecationWarning`` that was raised when pandas was imported without PyArrow being + installed has been removed. This decision was made because the warning was too noisy for too + many users and a lot of feedback was collected about the decision to make PyArrow a required + dependency. Pandas is currently considering the decision whether or not PyArrow should be added + as a hard dependency in 3.0. Interested users can follow the discussion + `here `_. + - Added the argument ``skipna`` to :meth:`DataFrameGroupBy.first`, :meth:`DataFrameGroupBy.last`, :meth:`SeriesGroupBy.first`, and :meth:`SeriesGroupBy.last`; achieving ``skipna=False`` used to be available via :meth:`DataFrameGroupBy.nth`, but the behavior was changed in pandas 2.0.0 (:issue:`57019`) - Added the argument ``skipna`` to :meth:`Resampler.first`, :meth:`Resampler.last` (:issue:`57019`) diff --git a/pandas/__init__.py b/pandas/__init__.py index 7b5b00d92db1f..f7ae91dd847f7 100644 --- a/pandas/__init__.py +++ b/pandas/__init__.py @@ -1,7 +1,5 @@ from __future__ import annotations -import warnings - __docformat__ = "restructuredtext" # Let users know if they're missing any of our hard dependencies @@ -190,36 +188,6 @@ __git_version__ = v.get("full-revisionid") del get_versions, v -# DeprecationWarning for missing pyarrow -from pandas.compat.pyarrow import pa_version_under10p1, pa_not_found - -if pa_version_under10p1: - # pyarrow is either too old or nonexistent, warn - from pandas.compat._optional import VERSIONS - - if pa_not_found: - pa_msg = "was not found to be installed on your system." - else: - pa_msg = ( - f"was too old on your system - pyarrow {VERSIONS['pyarrow']} " - "is the current minimum supported version as of this release." - ) - - warnings.warn( - f""" -Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0), -(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries) -but {pa_msg} -If this would cause problems for you, -please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466 - """, # noqa: E501 - DeprecationWarning, - stacklevel=2, - ) - del VERSIONS, pa_msg - -# Delete all unnecessary imported modules -del pa_version_under10p1, pa_not_found, warnings # module level doc-string __doc__ = """ diff --git a/pandas/compat/pyarrow.py b/pandas/compat/pyarrow.py index 2e151123ef2c9..beb4814914101 100644 --- a/pandas/compat/pyarrow.py +++ b/pandas/compat/pyarrow.py @@ -8,7 +8,6 @@ import pyarrow as pa _palv = Version(Version(pa.__version__).base_version) - pa_not_found = False pa_version_under10p1 = _palv < Version("10.0.1") pa_version_under11p0 = _palv < Version("11.0.0") pa_version_under12p0 = _palv < Version("12.0.0") @@ -17,7 +16,6 @@ pa_version_under14p1 = _palv < Version("14.0.1") pa_version_under15p0 = _palv < Version("15.0.0") except ImportError: - pa_not_found = True pa_version_under10p1 = True pa_version_under11p0 = True pa_version_under12p0 = True diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index 94d7d5fead622..9c2b9a76bbb83 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -8,8 +8,6 @@ import numpy as np import pytest -import pandas.util._test_decorators as td - import pandas as pd from pandas import Series import pandas._testing as tm @@ -255,26 +253,3 @@ def test_bz2_missing_import(): code = textwrap.dedent(code) call = [sys.executable, "-c", code] subprocess.check_output(call) - - -@td.skip_if_installed("pyarrow") -@pytest.mark.parametrize("module", ["pandas", "pandas.arrays"]) -def test_pyarrow_missing_warn(module): - # GH56896 - response = subprocess.run( - [sys.executable, "-c", f"import {module}"], - capture_output=True, - check=True, - ) - msg = """ -Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0), -(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries) -but was not found to be installed on your system. -If this would cause problems for you, -please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466 -""" # noqa: E501 - stderr_msg = response.stderr.decode("utf-8") - # Split by \n to avoid \r\n vs \n differences on Windows/Unix - # https://stackoverflow.com/questions/11989501/replacing-r-n-with-n - stderr_msg = "\n".join(stderr_msg.splitlines()) - assert msg in stderr_msg