diff --git a/ci/deps/actions-39-minimum_versions.yaml b/ci/deps/actions-39-minimum_versions.yaml index 91961e4af2d1c..7ad64e18ba993 100644 --- a/ci/deps/actions-39-minimum_versions.yaml +++ b/ci/deps/actions-39-minimum_versions.yaml @@ -22,7 +22,7 @@ dependencies: # required dependencies - python-dateutil=2.8.2 - - numpy=1.21.6 + - numpy=1.22.4 - pytz=2020.1 # optional dependencies diff --git a/doc/source/getting_started/install.rst b/doc/source/getting_started/install.rst index 572c695d0e09d..cc94ce853e4ef 100644 --- a/doc/source/getting_started/install.rst +++ b/doc/source/getting_started/install.rst @@ -203,7 +203,7 @@ pandas requires the following dependencies. ================================================================ ========================== Package Minimum supported version ================================================================ ========================== -`NumPy `__ 1.21.6 +`NumPy `__ 1.22.4 `python-dateutil `__ 2.8.2 `pytz `__ 2020.1 ================================================================ ========================== diff --git a/doc/source/whatsnew/v2.1.0.rst b/doc/source/whatsnew/v2.1.0.rst index b0d2acd9d3490..3d36c6c96b916 100644 --- a/doc/source/whatsnew/v2.1.0.rst +++ b/doc/source/whatsnew/v2.1.0.rst @@ -217,7 +217,7 @@ If installed, we now require: +-----------------+-----------------+----------+---------+ | Package | Minimum Version | Required | Changed | +=================+=================+==========+=========+ -| numpy | 1.21.6 | X | X | +| numpy | 1.22.4 | X | X | +-----------------+-----------------+----------+---------+ | mypy (dev) | 1.4.1 | | X | +-----------------+-----------------+----------+---------+ diff --git a/pandas/compat/numpy/__init__.py b/pandas/compat/numpy/__init__.py index d5dad2b8dc4bd..d376fa4c1919e 100644 --- a/pandas/compat/numpy/__init__.py +++ b/pandas/compat/numpy/__init__.py @@ -6,14 +6,11 @@ # numpy versioning _np_version = np.__version__ _nlv = Version(_np_version) -np_version_under1p22 = _nlv < Version("1.22") np_version_gte1p24 = _nlv >= Version("1.24") np_version_gte1p24p3 = _nlv >= Version("1.24.3") np_version_gte1p25 = _nlv >= Version("1.25") is_numpy_dev = _nlv.dev is not None -_min_numpy_ver = "1.21.6" - -np_percentile_argname = "interpolation" if np_version_under1p22 else "method" +_min_numpy_ver = "1.22.4" if _nlv < Version(_min_numpy_ver): diff --git a/pandas/core/array_algos/quantile.py b/pandas/core/array_algos/quantile.py index a824359a2f6c8..ee6f00b219a15 100644 --- a/pandas/core/array_algos/quantile.py +++ b/pandas/core/array_algos/quantile.py @@ -4,8 +4,6 @@ import numpy as np -from pandas.compat.numpy import np_percentile_argname - from pandas.core.dtypes.missing import ( isna, na_value_for_dtype, @@ -150,7 +148,7 @@ def _nanpercentile_1d( # error: No overload variant of "percentile" matches argument # types "ndarray[Any, Any]", "ndarray[Any, dtype[floating[_64Bit]]]" # , "Dict[str, str]" [call-overload] - **{np_percentile_argname: interpolation}, # type: ignore[call-overload] + method=interpolation, # type: ignore[call-overload] ) @@ -224,5 +222,5 @@ def _nanpercentile( # error: No overload variant of "percentile" matches argument types # "ndarray[Any, Any]", "ndarray[Any, dtype[floating[_64Bit]]]", # "int", "Dict[str, str]" [call-overload] - **{np_percentile_argname: interpolation}, # type: ignore[call-overload] + method=interpolation, # type: ignore[call-overload] ) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 68705097048d8..ddadf4e93bd72 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -54,10 +54,7 @@ from pandas.compat import PYPY from pandas.compat._constants import REF_COUNT from pandas.compat._optional import import_optional_dependency -from pandas.compat.numpy import ( - function as nv, - np_percentile_argname, -) +from pandas.compat.numpy import function as nv from pandas.errors import ( ChainedAssignmentError, InvalidIndexError, @@ -11699,9 +11696,7 @@ def quantile( dtype = self.dtype return self._constructor([], index=q, columns=data.columns, dtype=dtype) - q_idx = np.quantile( # type: ignore[call-overload] - np.arange(len(data)), q, **{np_percentile_argname: interpolation} - ) + q_idx = np.quantile(np.arange(len(data)), q, method=interpolation) by = data.columns if len(by) > 1: diff --git a/pandas/tests/frame/methods/test_quantile.py b/pandas/tests/frame/methods/test_quantile.py index 0d9f4bd77d137..f91f01d4bc91e 100644 --- a/pandas/tests/frame/methods/test_quantile.py +++ b/pandas/tests/frame/methods/test_quantile.py @@ -1,8 +1,6 @@ import numpy as np import pytest -from pandas.compat.numpy import np_percentile_argname - import pandas as pd from pandas import ( DataFrame, @@ -262,7 +260,7 @@ def test_quantile_interpolation(self): np.array([[1, 2, 3], [2, 3, 4]]), 0.5, axis=0, - **{np_percentile_argname: "nearest"}, + method="nearest", ) expected = Series(exp, index=[1, 2, 3], name=0.5, dtype="int64") tm.assert_series_equal(result, expected) @@ -276,7 +274,7 @@ def test_quantile_interpolation(self): np.array([[1.0, 2.0, 3.0], [2.0, 3.0, 4.0]]), 0.5, axis=0, - **{np_percentile_argname: "nearest"}, + method="nearest", ) expected = Series(exp, index=[1, 2, 3], name=0.5, dtype="float64") tm.assert_series_equal(result, expected) diff --git a/pyproject.toml b/pyproject.toml index f5e903d0b5c8c..654b8c5a493d4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ requires = [ # we don't want to force users to compile with 1.25 though # (Ideally, in the future, though, oldest-supported-numpy can be dropped when our min numpy is 1.25.x) "oldest-supported-numpy>=2022.8.16; python_version<'3.12'", - "numpy>=1.21.6; python_version>='3.12'", + "numpy>=1.22.4; python_version>='3.12'", "versioneer[toml]" ] @@ -29,7 +29,7 @@ authors = [ license = {file = 'LICENSE'} requires-python = '>=3.9' dependencies = [ - "numpy>=1.21.6; python_version<'3.11'", + "numpy>=1.22.4; python_version<'3.11'", "numpy>=1.23.2; python_version>='3.11'", "python-dateutil>=2.8.2", "pytz>=2020.1",