Skip to content

Commit d80292c

Browse files
authored
📌 Require pandas~=2.1 and drop support for python 3.8 (#62)
* 📌 Require pandas~=2.1 * Drop support for python 3.8 * Update type checks
1 parent 73fd310 commit d80292c

File tree

6 files changed

+10
-15
lines changed

6 files changed

+10
-15
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
runs-on: ubuntu-20.04
1818
strategy:
1919
matrix:
20-
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
20+
python-version: ['3.9', '3.10', '3.11', '3.12']
2121

2222
steps:
2323
- uses: actions/checkout@v4

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@ description = "Sensible multi-core apply function for Pandas"
88
readme = "README.md"
99
urls = {Repository = "https://github.com/ddelange/mapply", Documentation = "https://mapply.readthedocs.io"}
1010
authors = [{name = "ddelange", email = "ddelange@delange.dev"}]
11-
requires-python = ">=3.8" # sync with classifiers below, and tool.ruff and tool.mypy
11+
requires-python = ">=3.9" # sync with classifiers below, and tool.ruff and tool.mypy
1212
classifiers = [
1313
"Development Status :: 5 - Production/Stable",
1414
"Intended Audience :: Developers",
1515
"Operating System :: OS Independent",
1616
"License :: OSI Approved :: MIT License",
1717
"Programming Language :: Python",
1818
"Programming Language :: Python :: 3",
19-
"Programming Language :: Python :: 3.8",
2019
"Programming Language :: Python :: 3.9",
2120
"Programming Language :: Python :: 3.10",
2221
"Programming Language :: Python :: 3.11",
@@ -31,7 +30,7 @@ branch = true
3130
omit = ["site-packages"]
3231

3332
[tool.mypy]
34-
python_version = "3.8"
33+
python_version = "3.9"
3534
ignore_missing_imports = true
3635
warn_no_return = false
3736
disallow_untyped_defs = false
@@ -58,6 +57,7 @@ ignore = [
5857
"D203", # there is D211
5958
"D213", # there is D212
6059
"FIX002", # there is TD002,TD003
60+
"TCH003", # clutters
6161
]
6262

6363
[tool.ruff.extend-per-file-ignores]

requirements/ci.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ mypy~=1.6
33
pre-commit~=3.5
44
pytest-cov~=4.1
55
pytest~=7.4
6-
pandas

requirements/prod.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pathos>=0.3.1 # https://github.com/uqfoundation/pathos/pull/252
22
multiprocess
33
psutil
44
tqdm>=4.27 # from tqdm.auto import tqdm
5+
pandas~=2.1

src/mapply/_groupby.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# ruff: noqa: ERA001
3434
import logging
3535
from types import MethodType
36-
from typing import Any, Callable, Tuple
36+
from typing import Any, Callable
3737

3838
from mapply.parallel import multiprocessing_imap, tqdm
3939

@@ -46,11 +46,10 @@ def run_groupwise_apply(
4646
*,
4747
n_workers: int,
4848
progressbar: bool,
49-
args: Tuple[Any, ...] = (), # noqa: FA100
49+
args: tuple[Any, ...] = (),
5050
**kwargs: Any,
5151
):
5252
"""Patch GroupBy.grouper.apply, applying func to each group in parallel."""
53-
from pandas import __version__
5453

5554
def apply(self, f, data, axis=0):
5655
# patching https://github.com/pandas-dev/pandas/blob/v1.5.3/pandas/core/groupby/ops.py#L823
@@ -118,13 +117,8 @@ def apply(self, f, data, axis=0):
118117

119118
return result_values, mutated
120119

121-
if __version__.split(".") < ["1", "5"]: # pragma: no cover
122-
logger.warning("GroupBy.mapply only works for pandas>=1.5.0. Using single CPU.")
123-
return df_or_series.apply(func, *args, **kwargs)
124-
125-
# 2.1.0 renamed to apply_groupwise ref https://github.com/pandas-dev/pandas/commit/dc947a459b094ccd087557db355cfde5ed97b454
126-
attr = "apply" if hasattr(df_or_series.grouper, "apply") else "apply_groupwise"
127120
# overwrite apply method and restore after execution
121+
attr = "apply_groupwise"
128122
original_apply = getattr(df_or_series.grouper, attr)
129123
setattr(df_or_series.grouper, attr, MethodType(apply, df_or_series.grouper))
130124
try:

src/mapply/parallel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ def some_heavy_computation(x, power):
5454

5555
import logging
5656
import os
57+
from collections.abc import Iterable, Iterator
5758
from functools import partial
58-
from typing import Any, Callable, Iterable, Iterator
59+
from typing import Any, Callable
5960

6061
import multiprocess
6162
import psutil

0 commit comments

Comments
 (0)