Skip to content

DEPS: drop np 1.21 #54323

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/deps/actions-39-minimum_versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion doc/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ pandas requires the following dependencies.
================================================================ ==========================
Package Minimum supported version
================================================================ ==========================
`NumPy <https://numpy.org>`__ 1.21.6
`NumPy <https://numpy.org>`__ 1.22.4
`python-dateutil <https://dateutil.readthedocs.io/en/stable/>`__ 2.8.2
`pytz <https://pypi.org/project/pytz/>`__ 2020.1
================================================================ ==========================
Expand Down
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
+-----------------+-----------------+----------+---------+
Expand Down
5 changes: 1 addition & 4 deletions pandas/compat/numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 2 additions & 4 deletions pandas/core/array_algos/quantile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
)


Expand Down Expand Up @@ -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]
)
9 changes: 2 additions & 7 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/frame/methods/test_quantile.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
]

Expand All @@ -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",
Expand Down