Skip to content

Commit 69bbab5

Browse files
GH1246 Upgrade to pandas 2.3.0
1 parent 320cf41 commit 69bbab5

13 files changed

+222
-148
lines changed

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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +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_23 = Version(pd.__version__) < Version("2.3.999")
5354
PD_LTE_22 = Version(pd.__version__) < Version("2.2.999")
5455
NUMPY20 = np.lib.NumpyVersion(np.__version__) >= "2.0.0"
5556

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: 78 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
from tests import (
5151
PD_LTE_22,
52+
PD_LTE_23,
5253
TYPE_CHECKING_INVALID_USAGE,
5354
check,
5455
ensure_clean,
@@ -450,7 +451,7 @@ def test_types_drop_duplicates() -> None:
450451
pd.DataFrame,
451452
)
452453

453-
if not PD_LTE_22:
454+
if not PD_LTE_23:
454455
check(assert_type(df.drop_duplicates({"AAA"}), pd.DataFrame), pd.DataFrame)
455456
check(
456457
assert_type(df.drop_duplicates({"AAA": None}), pd.DataFrame), pd.DataFrame
@@ -1602,7 +1603,7 @@ def wrapped_min(x: Any) -> Any:
16021603
with pytest_warns_bounded(
16031604
FutureWarning,
16041605
r"The provided callable <built-in function (min|max)> is currently using",
1605-
upper="2.2.99",
1606+
upper="2.3.99",
16061607
):
16071608
check(assert_type(df.groupby("col1")["col3"].agg(min), pd.Series), pd.Series)
16081609
check(
@@ -1751,7 +1752,7 @@ def test_types_window() -> None:
17511752
with pytest_warns_bounded(
17521753
FutureWarning,
17531754
r"The provided callable <built-in function (min|max)> is currently using",
1754-
upper="2.2.99",
1755+
upper="2.3.99",
17551756
):
17561757
check(
17571758
assert_type(df.rolling(2).agg(max), pd.DataFrame),
@@ -1860,7 +1861,7 @@ def test_types_agg() -> None:
18601861
with pytest_warns_bounded(
18611862
FutureWarning,
18621863
r"The provided callable <(built-in function (min|max|mean)|function mean at 0x\w+)> is currently using",
1863-
upper="2.2.99",
1864+
upper="2.3.99",
18641865
):
18651866
check(assert_type(df.agg(min), pd.Series), pd.Series)
18661867
check(assert_type(df.agg([min, max]), pd.DataFrame), pd.DataFrame)
@@ -1887,7 +1888,7 @@ def test_types_aggregate() -> None:
18871888
with pytest_warns_bounded(
18881889
FutureWarning,
18891890
r"The provided callable <built-in function (min|max)> is currently using",
1890-
upper="2.2.99",
1891+
upper="2.3.99",
18911892
):
18921893
check(assert_type(df.aggregate(min), pd.Series), pd.Series)
18931894
check(assert_type(df.aggregate([min, max]), pd.DataFrame), pd.DataFrame)
@@ -2020,7 +2021,7 @@ def test_types_resample() -> None:
20202021
FutureWarning,
20212022
"'M' is deprecated",
20222023
lower="2.1.99",
2023-
upper="2.2.99",
2024+
upper="2.3.99",
20242025
upper_exception=ValueError,
20252026
):
20262027
df.resample("M", on="date")
@@ -2163,7 +2164,7 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame:
21632164
FutureWarning,
21642165
"'M' is deprecated",
21652166
lower="2.1.99",
2166-
upper="2.2.99",
2167+
upper="2.3.99",
21672168
upper_exception=ValueError,
21682169
):
21692170
(
@@ -2504,7 +2505,7 @@ def test_types_regressions() -> None:
25042505
tslist = list(pd.to_datetime(["2022-01-01", "2022-01-02"]))
25052506
check(assert_type(tslist, list[pd.Timestamp]), list, pd.Timestamp)
25062507
sseries = pd.Series(tslist)
2507-
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.2.99"):
2508+
with pytest_warns_bounded(FutureWarning, "'d' is deprecated", lower="2.3.99"):
25082509
sseries + pd.Timedelta(1, "d")
25092510

25102511
check(
@@ -2518,7 +2519,7 @@ def test_types_regressions() -> None:
25182519
FutureWarning,
25192520
"'H' is deprecated",
25202521
lower="2.1.99",
2521-
upper="2.2.99",
2522+
upper="2.3.99",
25222523
upper_exception=ValueError,
25232524
):
25242525
pd.date_range(start="2021-12-01", periods=24, freq="H")
@@ -2644,7 +2645,7 @@ class ReadCsvKwargs(TypedDict):
26442645
),
26452646
pd.DataFrame,
26462647
)
2647-
if PD_LTE_22:
2648+
if PD_LTE_23:
26482649
parse_dates_2 = {"combined_date": ["Year", "Month", "Day"]}
26492650
with pytest_warns_bounded(
26502651
FutureWarning,
@@ -3098,7 +3099,7 @@ def test_frame_stack() -> None:
30983099
with pytest_warns_bounded(
30993100
FutureWarning,
31003101
"The previous implementation of stack is deprecated",
3101-
upper="2.2.99",
3102+
upper="2.3.99",
31023103
):
31033104
check(
31043105
assert_type(
@@ -3113,7 +3114,7 @@ def test_frame_stack() -> None:
31133114
),
31143115
pd.Series,
31153116
)
3116-
if PD_LTE_22:
3117+
if PD_LTE_23:
31173118
check(
31183119
assert_type(
31193120
df_multi_level_cols2.stack(0, future_stack=False),
@@ -3145,7 +3146,7 @@ def test_frame_reindex_like() -> None:
31453146
FutureWarning,
31463147
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'",
31473148
lower="2.2.99",
3148-
upper="3.0.99",
3149+
upper="2.2.99",
31493150
):
31503151
check(
31513152
assert_type(
@@ -3277,7 +3278,7 @@ def test_groupby_result() -> None:
32773278
index, value = next(iterator)
32783279
assert_type((index, value), tuple[tuple, pd.DataFrame])
32793280

3280-
if PD_LTE_22:
3281+
if PD_LTE_23:
32813282
check(assert_type(index, tuple), tuple, np.integer)
32823283
else:
32833284
check(assert_type(index, tuple), tuple, int)
@@ -3389,7 +3390,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None:
33893390
with pytest_warns_bounded(
33903391
FutureWarning,
33913392
"The default of observed=False is deprecated",
3392-
upper="2.2.99",
3393+
upper="2.3.99",
33933394
):
33943395
categorical_index = pd.CategoricalIndex(df.a)
33953396
iterator2 = df.groupby(categorical_index).__iter__()
@@ -3448,41 +3449,72 @@ def test_groupby_apply() -> None:
34483449
def sum_mean(x: pd.DataFrame) -> float:
34493450
return x.sum().mean()
34503451

3451-
with pytest_warns_bounded(
3452-
DeprecationWarning,
3453-
"DataFrameGroupBy.apply operated on the grouping columns.",
3454-
upper="2.99",
3452+
with (
3453+
pytest_warns_bounded(
3454+
DeprecationWarning,
3455+
"DataFrameGroupBy.apply operated on the grouping columns.",
3456+
upper="2.2.99",
3457+
),
3458+
pytest_warns_bounded(
3459+
FutureWarning,
3460+
"DataFrameGroupBy.apply operated on the grouping columns.",
3461+
lower="2.2.99",
3462+
upper="2.3.99",
3463+
),
34553464
):
34563465
check(
34573466
assert_type(df.groupby("col1").apply(sum_mean), pd.Series),
34583467
pd.Series,
34593468
)
34603469

34613470
lfunc: Callable[[pd.DataFrame], float] = lambda x: x.sum().mean()
3462-
with pytest_warns_bounded(
3463-
DeprecationWarning,
3464-
"DataFrameGroupBy.apply operated on the grouping columns.",
3465-
upper="2.99",
3471+
with (
3472+
pytest_warns_bounded(
3473+
DeprecationWarning,
3474+
"DataFrameGroupBy.apply operated on the grouping columns.",
3475+
upper="2.2.99",
3476+
),
3477+
pytest_warns_bounded(
3478+
FutureWarning,
3479+
"DataFrameGroupBy.apply operated on the grouping columns.",
3480+
lower="2.2.99",
3481+
),
34663482
):
34673483
check(assert_type(df.groupby("col1").apply(lfunc), pd.Series), pd.Series)
34683484

34693485
def sum_to_list(x: pd.DataFrame) -> list:
34703486
return x.sum().tolist()
34713487

3472-
with pytest_warns_bounded(
3473-
DeprecationWarning,
3474-
"DataFrameGroupBy.apply operated on the grouping columns.",
3475-
upper="2.99",
3488+
with (
3489+
pytest_warns_bounded(
3490+
DeprecationWarning,
3491+
"DataFrameGroupBy.apply operated on the grouping columns.",
3492+
upper="2.2.99",
3493+
),
3494+
pytest_warns_bounded(
3495+
FutureWarning,
3496+
"DataFrameGroupBy.apply operated on the grouping columns.",
3497+
lower="2.2.99",
3498+
upper="2.3.99",
3499+
),
34763500
):
34773501
check(assert_type(df.groupby("col1").apply(sum_to_list), pd.Series), pd.Series)
34783502

34793503
def sum_to_series(x: pd.DataFrame) -> pd.Series:
34803504
return x.sum()
34813505

3482-
with pytest_warns_bounded(
3483-
DeprecationWarning,
3484-
"DataFrameGroupBy.apply operated on the grouping columns.",
3485-
upper="2.99",
3506+
with (
3507+
pytest_warns_bounded(
3508+
DeprecationWarning,
3509+
"DataFrameGroupBy.apply operated on the grouping columns.",
3510+
upper="2.2.99",
3511+
),
3512+
pytest_warns_bounded(
3513+
FutureWarning,
3514+
"DataFrameGroupBy.apply operated on the grouping columns.",
3515+
lower="2.2.99",
3516+
upper="2.3.99",
3517+
),
34863518
):
34873519
check(
34883520
assert_type(df.groupby("col1").apply(sum_to_series), pd.DataFrame),
@@ -3492,10 +3524,18 @@ def sum_to_series(x: pd.DataFrame) -> pd.Series:
34923524
def sample_to_df(x: pd.DataFrame) -> pd.DataFrame:
34933525
return x.sample()
34943526

3495-
with pytest_warns_bounded(
3496-
DeprecationWarning,
3497-
"DataFrameGroupBy.apply operated on the grouping columns.",
3498-
upper="2.99",
3527+
with (
3528+
pytest_warns_bounded(
3529+
DeprecationWarning,
3530+
"DataFrameGroupBy.apply operated on the grouping columns.",
3531+
upper="2.2.99",
3532+
),
3533+
pytest_warns_bounded(
3534+
FutureWarning,
3535+
"DataFrameGroupBy.apply operated on the grouping columns.",
3536+
lower="2.2.99",
3537+
upper="2.3.99",
3538+
),
34993539
):
35003540
check(
35013541
assert_type(
@@ -3769,7 +3809,7 @@ def test_resample_150_changes() -> None:
37693809
FutureWarning,
37703810
"'M' is deprecated",
37713811
lower="2.1.99",
3772-
upper="2.2.99",
3812+
upper="2.3.99",
37733813
upper_exception=ValueError,
37743814
):
37753815
frame.resample("M", group_keys=True)
@@ -3872,7 +3912,7 @@ def test_getattr_and_dataframe_groupby() -> None:
38723912
with pytest_warns_bounded(
38733913
FutureWarning,
38743914
r"The provided callable <built-in function (min|max)> is currently using",
3875-
upper="2.2.99",
3915+
upper="2.3.99",
38763916
):
38773917
check(assert_type(df.groupby("col1").col3.agg(min), pd.Series), pd.Series)
38783918
check(
@@ -4390,6 +4430,7 @@ def test_transpose() -> None:
43904430
DeprecationWarning,
43914431
msg,
43924432
lower="2.2.99",
4433+
upper="2.2.99",
43934434
):
43944435
check(assert_type(df.transpose(copy=True), pd.DataFrame), pd.DataFrame)
43954436

0 commit comments

Comments
 (0)