Skip to content

Commit d4d7e4c

Browse files
GH1246 Upgrade to pandas 2.3.0 (#1247)
* GH1246 Upgrade to pandas 2.3.0 * GH1246 PR feedback * GH1246 PR feedback
1 parent 32fdfe4 commit d4d7e4c

14 files changed

+139
-133
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ repos:
1111
hooks:
1212
- id: isort
1313
- repo: https://github.com/astral-sh/ruff-pre-commit
14-
rev: v0.11.5
14+
rev: v0.11.13
1515
hooks:
1616
- id: ruff
1717
args: [

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ty = "^0.0.1a8"
3737

3838
[tool.poetry.group.dev.dependencies]
3939
mypy = "1.16.0"
40-
pandas = "2.2.3"
40+
pandas = "2.3.0"
4141
pyarrow = ">=10.0.1"
4242
pytest = ">=7.1.2"
4343
pyright = ">=1.1.400"

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
TYPE_CHECKING_INVALID_USAGE: Final = TYPE_CHECKING
5252
WINDOWS = os.name == "nt" or "cygwin" in platform.system().lower()
53-
PD_LTE_22 = Version(pd.__version__) < Version("2.2.999")
53+
PD_LTE_23 = Version(pd.__version__) < Version("2.3.999")
5454
NUMPY20 = np.lib.NumpyVersion(np.__version__) >= "2.0.0"
5555

5656

tests/test_errors.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import pytest
55

66
from tests import (
7-
PD_LTE_22,
7+
PD_LTE_23,
88
WINDOWS,
99
)
1010

@@ -108,13 +108,13 @@ def test_specification_error() -> None:
108108

109109

110110
def test_setting_with_copy_error() -> None:
111-
if PD_LTE_22:
111+
if PD_LTE_23:
112112
with pytest.raises(errors.SettingWithCopyError):
113113
raise errors.SettingWithCopyError()
114114

115115

116116
def test_setting_with_copy_warning() -> None:
117-
if PD_LTE_22:
117+
if PD_LTE_23:
118118
with pytest.warns(errors.SettingWithCopyWarning):
119119
warnings.warn("", errors.SettingWithCopyWarning)
120120

tests/test_frame.py

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
from pandas._typing import Scalar
4949

5050
from tests import (
51-
PD_LTE_22,
51+
PD_LTE_23,
5252
TYPE_CHECKING_INVALID_USAGE,
5353
check,
5454
ensure_clean,
@@ -450,7 +450,7 @@ def test_types_drop_duplicates() -> None:
450450
pd.DataFrame,
451451
)
452452

453-
if not PD_LTE_22:
453+
if not PD_LTE_23:
454454
check(assert_type(df.drop_duplicates({"AAA"}), pd.DataFrame), pd.DataFrame)
455455
check(
456456
assert_type(df.drop_duplicates({"AAA": None}), pd.DataFrame), pd.DataFrame
@@ -1544,14 +1544,14 @@ def test_types_groupby() -> None:
15441544
with pytest_warns_bounded(
15451545
FutureWarning,
15461546
"(The provided callable <built-in function sum> is currently using|The behavior of DataFrame.sum with)",
1547-
upper="2.2.99",
1547+
upper="2.3.99",
15481548
):
15491549
with pytest_warns_bounded(
1550-
DeprecationWarning,
1550+
FutureWarning,
15511551
"DataFrameGroupBy.apply operated on the grouping columns",
1552-
upper="2.2.99",
1552+
upper="2.3.99",
15531553
):
1554-
if PD_LTE_22:
1554+
if PD_LTE_23:
15551555
check(
15561556
assert_type(df.groupby(by="col1").apply(sum), pd.DataFrame),
15571557
pd.DataFrame,
@@ -1602,7 +1602,7 @@ def wrapped_min(x: Any) -> Any:
16021602
with pytest_warns_bounded(
16031603
FutureWarning,
16041604
r"The provided callable <built-in function (min|max)> is currently using",
1605-
upper="2.2.99",
1605+
upper="2.3.99",
16061606
):
16071607
check(assert_type(df.groupby("col1")["col3"].agg(min), pd.Series), pd.Series)
16081608
check(
@@ -1751,7 +1751,7 @@ def test_types_window() -> None:
17511751
with pytest_warns_bounded(
17521752
FutureWarning,
17531753
r"The provided callable <built-in function (min|max)> is currently using",
1754-
upper="2.2.99",
1754+
upper="2.3.99",
17551755
):
17561756
check(
17571757
assert_type(df.rolling(2).agg(max), pd.DataFrame),
@@ -1860,7 +1860,7 @@ def test_types_agg() -> None:
18601860
with pytest_warns_bounded(
18611861
FutureWarning,
18621862
r"The provided callable <(built-in function (min|max|mean)|function mean at 0x\w+)> is currently using",
1863-
upper="2.2.99",
1863+
upper="2.3.99",
18641864
):
18651865
check(assert_type(df.agg(min), pd.Series), pd.Series)
18661866
check(assert_type(df.agg([min, max]), pd.DataFrame), pd.DataFrame)
@@ -1887,7 +1887,7 @@ def test_types_aggregate() -> None:
18871887
with pytest_warns_bounded(
18881888
FutureWarning,
18891889
r"The provided callable <built-in function (min|max)> is currently using",
1890-
upper="2.2.99",
1890+
upper="2.3.99",
18911891
):
18921892
check(assert_type(df.aggregate(min), pd.Series), pd.Series)
18931893
check(assert_type(df.aggregate([min, max]), pd.DataFrame), pd.DataFrame)
@@ -2020,7 +2020,7 @@ def test_types_resample() -> None:
20202020
FutureWarning,
20212021
"'M' is deprecated",
20222022
lower="2.1.99",
2023-
upper="2.2.99",
2023+
upper="2.3.99",
20242024
upper_exception=ValueError,
20252025
):
20262026
df.resample("M", on="date")
@@ -2163,7 +2163,7 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame:
21632163
FutureWarning,
21642164
"'M' is deprecated",
21652165
lower="2.1.99",
2166-
upper="2.2.99",
2166+
upper="2.3.99",
21672167
upper_exception=ValueError,
21682168
):
21692169
(
@@ -2504,7 +2504,7 @@ def test_types_regressions() -> None:
25042504
tslist = list(pd.to_datetime(["2022-01-01", "2022-01-02"]))
25052505
check(assert_type(tslist, list[pd.Timestamp]), list, pd.Timestamp)
25062506
sseries = pd.Series(tslist)
2507-
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"):
2507+
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"):
25082508
sseries + pd.Timedelta(1, "d")
25092509

25102510
check(
@@ -2518,7 +2518,7 @@ def test_types_regressions() -> None:
25182518
FutureWarning,
25192519
"'H' is deprecated",
25202520
lower="2.1.99",
2521-
upper="2.2.99",
2521+
upper="2.3.99",
25222522
upper_exception=ValueError,
25232523
):
25242524
pd.date_range(start="2021-12-01", periods=24, freq="H")
@@ -2644,7 +2644,7 @@ class ReadCsvKwargs(TypedDict):
26442644
),
26452645
pd.DataFrame,
26462646
)
2647-
if PD_LTE_22:
2647+
if PD_LTE_23:
26482648
parse_dates_2 = {"combined_date": ["Year", "Month", "Day"]}
26492649
with pytest_warns_bounded(
26502650
FutureWarning,
@@ -3098,7 +3098,7 @@ def test_frame_stack() -> None:
30983098
with pytest_warns_bounded(
30993099
FutureWarning,
31003100
"The previous implementation of stack is deprecated",
3101-
upper="2.2.99",
3101+
upper="2.3.99",
31023102
):
31033103
check(
31043104
assert_type(
@@ -3113,7 +3113,7 @@ def test_frame_stack() -> None:
31133113
),
31143114
pd.Series,
31153115
)
3116-
if PD_LTE_22:
3116+
if PD_LTE_23:
31173117
check(
31183118
assert_type(
31193119
df_multi_level_cols2.stack(0, future_stack=False),
@@ -3133,19 +3133,17 @@ def test_frame_stack() -> None:
31333133
def test_frame_reindex() -> None:
31343134
# GH 84
31353135
df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2])
3136-
df.reindex([2, 1, 0])
3136+
check(assert_type(df.reindex([2, 1, 0]), pd.DataFrame), pd.DataFrame)
31373137

31383138

31393139
def test_frame_reindex_like() -> None:
31403140
# GH 84
31413141
df = pd.DataFrame({"a": [1, 2, 3]}, index=[0, 1, 2])
31423142
other = pd.DataFrame({"a": [1, 2]}, index=[1, 0])
3143-
31443143
with pytest_warns_bounded(
31453144
FutureWarning,
31463145
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
3147-
lower="2.2.99",
3148-
upper="3.0.99",
3146+
lower="2.3.0",
31493147
):
31503148
check(
31513149
assert_type(
@@ -3277,7 +3275,7 @@ def test_groupby_result() -> None:
32773275
index, value = next(iterator)
32783276
assert_type((index, value), tuple[tuple, pd.DataFrame])
32793277

3280-
if PD_LTE_22:
3278+
if PD_LTE_23:
32813279
check(assert_type(index, tuple), tuple, np.integer)
32823280
else:
32833281
check(assert_type(index, tuple), tuple, int)
@@ -3389,7 +3387,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None:
33893387
with pytest_warns_bounded(
33903388
FutureWarning,
33913389
"The default of observed=False is deprecated",
3392-
upper="2.2.99",
3390+
upper="2.3.99",
33933391
):
33943392
categorical_index = pd.CategoricalIndex(df.a)
33953393
iterator2 = df.groupby(categorical_index).__iter__()
@@ -3449,8 +3447,9 @@ def sum_mean(x: pd.DataFrame) -> float:
34493447
return x.sum().mean()
34503448

34513449
with pytest_warns_bounded(
3452-
DeprecationWarning,
3450+
FutureWarning,
34533451
"DataFrameGroupBy.apply operated on the grouping columns.",
3452+
lower="2.2.99",
34543453
upper="2.99",
34553454
):
34563455
check(
@@ -3460,8 +3459,9 @@ def sum_mean(x: pd.DataFrame) -> float:
34603459

34613460
lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean()
34623461
with pytest_warns_bounded(
3463-
DeprecationWarning,
3462+
FutureWarning,
34643463
"DataFrameGroupBy.apply operated on the grouping columns.",
3464+
lower="2.2.99",
34653465
upper="2.99",
34663466
):
34673467
check(assert_type(df.groupby("col1").apply(lfunc), pd.Series), pd.Series)
@@ -3470,8 +3470,9 @@ def sum_to_list(x: pd.DataFrame) -> list:
34703470
return x.sum().tolist()
34713471

34723472
with pytest_warns_bounded(
3473-
DeprecationWarning,
3473+
FutureWarning,
34743474
"DataFrameGroupBy.apply operated on the grouping columns.",
3475+
lower="2.2.99",
34753476
upper="2.99",
34763477
):
34773478
check(assert_type(df.groupby("col1").apply(sum_to_list), pd.Series), pd.Series)
@@ -3480,8 +3481,9 @@ def sum_to_series(x: pd.DataFrame) -> pd.Series:
34803481
return x.sum()
34813482

34823483
with pytest_warns_bounded(
3483-
DeprecationWarning,
3484+
FutureWarning,
34843485
"DataFrameGroupBy.apply operated on the grouping columns.",
3486+
lower="2.2.99",
34853487
upper="2.99",
34863488
):
34873489
check(
@@ -3493,8 +3495,9 @@ def sample_to_df(x: pd.DataFrame) -> pd.DataFrame:
34933495
return x.sample()
34943496

34953497
with pytest_warns_bounded(
3496-
DeprecationWarning,
3498+
FutureWarning,
34973499
"DataFrameGroupBy.apply operated on the grouping columns.",
3500+
lower="2.2.99",
34983501
upper="2.99",
34993502
):
35003503
check(
@@ -3769,7 +3772,7 @@ def test_resample_150_changes() -> None:
37693772
FutureWarning,
37703773
"'M' is deprecated",
37713774
lower="2.1.99",
3772-
upper="2.2.99",
3775+
upper="2.99",
37733776
upper_exception=ValueError,
37743777
):
37753778
frame.resample("M", group_keys=True)
@@ -3872,7 +3875,7 @@ def test_getattr_and_dataframe_groupby() -> None:
38723875
with pytest_warns_bounded(
38733876
FutureWarning,
38743877
r"The provided callable <built-in function (min|max)> is currently using",
3875-
upper="2.2.99",
3878+
upper="2.3.99",
38763879
):
38773880
check(assert_type(df.groupby("col1").col3.agg(min), pd.Series), pd.Series)
38783881
check(
@@ -4384,12 +4387,11 @@ def test_transpose() -> None:
43844387
df = pd.DataFrame({"a": [1, 1, 2], "b": [4, 5, 6]})
43854388
check(assert_type(df.transpose(), pd.DataFrame), pd.DataFrame)
43864389
check(assert_type(df.transpose(None), pd.DataFrame), pd.DataFrame)
4387-
43884390
msg = "The copy keyword is deprecated and will be removed in a future"
43894391
with pytest_warns_bounded(
43904392
DeprecationWarning,
43914393
msg,
4392-
lower="2.2.99",
4394+
lower="2.3.99",
43934395
):
43944396
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)
43954397

0 commit comments

Comments
 (0)