48
48
from pandas ._typing import Scalar
49
49
50
50
from tests import (
51
- PD_LTE_22 ,
51
+ PD_LTE_23 ,
52
52
TYPE_CHECKING_INVALID_USAGE ,
53
53
check ,
54
54
ensure_clean ,
@@ -450,7 +450,7 @@ def test_types_drop_duplicates() -> None:
450
450
pd .DataFrame ,
451
451
)
452
452
453
- if not PD_LTE_22 :
453
+ if not PD_LTE_23 :
454
454
check (assert_type (df .drop_duplicates ({"AAA" }), pd .DataFrame ), pd .DataFrame )
455
455
check (
456
456
assert_type (df .drop_duplicates ({"AAA" : None }), pd .DataFrame ), pd .DataFrame
@@ -1544,14 +1544,14 @@ def test_types_groupby() -> None:
1544
1544
with pytest_warns_bounded (
1545
1545
FutureWarning ,
1546
1546
"(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" ,
1548
1548
):
1549
1549
with pytest_warns_bounded (
1550
- DeprecationWarning ,
1550
+ FutureWarning ,
1551
1551
"DataFrameGroupBy.apply operated on the grouping columns" ,
1552
- upper = "2.2 .99" ,
1552
+ upper = "2.3 .99" ,
1553
1553
):
1554
- if PD_LTE_22 :
1554
+ if PD_LTE_23 :
1555
1555
check (
1556
1556
assert_type (df .groupby (by = "col1" ).apply (sum ), pd .DataFrame ),
1557
1557
pd .DataFrame ,
@@ -1602,7 +1602,7 @@ def wrapped_min(x: Any) -> Any:
1602
1602
with pytest_warns_bounded (
1603
1603
FutureWarning ,
1604
1604
r"The provided callable <built-in function (min|max)> is currently using" ,
1605
- upper = "2.2 .99" ,
1605
+ upper = "2.3 .99" ,
1606
1606
):
1607
1607
check (assert_type (df .groupby ("col1" )["col3" ].agg (min ), pd .Series ), pd .Series )
1608
1608
check (
@@ -1751,7 +1751,7 @@ def test_types_window() -> None:
1751
1751
with pytest_warns_bounded (
1752
1752
FutureWarning ,
1753
1753
r"The provided callable <built-in function (min|max)> is currently using" ,
1754
- upper = "2.2 .99" ,
1754
+ upper = "2.3 .99" ,
1755
1755
):
1756
1756
check (
1757
1757
assert_type (df .rolling (2 ).agg (max ), pd .DataFrame ),
@@ -1860,7 +1860,7 @@ def test_types_agg() -> None:
1860
1860
with pytest_warns_bounded (
1861
1861
FutureWarning ,
1862
1862
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" ,
1864
1864
):
1865
1865
check (assert_type (df .agg (min ), pd .Series ), pd .Series )
1866
1866
check (assert_type (df .agg ([min , max ]), pd .DataFrame ), pd .DataFrame )
@@ -1887,7 +1887,7 @@ def test_types_aggregate() -> None:
1887
1887
with pytest_warns_bounded (
1888
1888
FutureWarning ,
1889
1889
r"The provided callable <built-in function (min|max)> is currently using" ,
1890
- upper = "2.2 .99" ,
1890
+ upper = "2.3 .99" ,
1891
1891
):
1892
1892
check (assert_type (df .aggregate (min ), pd .Series ), pd .Series )
1893
1893
check (assert_type (df .aggregate ([min , max ]), pd .DataFrame ), pd .DataFrame )
@@ -2020,7 +2020,7 @@ def test_types_resample() -> None:
2020
2020
FutureWarning ,
2021
2021
"'M' is deprecated" ,
2022
2022
lower = "2.1.99" ,
2023
- upper = "2.2 .99" ,
2023
+ upper = "2.3 .99" ,
2024
2024
upper_exception = ValueError ,
2025
2025
):
2026
2026
df .resample ("M" , on = "date" )
@@ -2163,7 +2163,7 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame:
2163
2163
FutureWarning ,
2164
2164
"'M' is deprecated" ,
2165
2165
lower = "2.1.99" ,
2166
- upper = "2.2 .99" ,
2166
+ upper = "2.3 .99" ,
2167
2167
upper_exception = ValueError ,
2168
2168
):
2169
2169
(
@@ -2504,7 +2504,7 @@ def test_types_regressions() -> None:
2504
2504
tslist = list (pd .to_datetime (["2022-01-01" , "2022-01-02" ]))
2505
2505
check (assert_type (tslist , list [pd .Timestamp ]), list , pd .Timestamp )
2506
2506
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" ):
2508
2508
sseries + pd .Timedelta (1 , "d" )
2509
2509
2510
2510
check (
@@ -2518,7 +2518,7 @@ def test_types_regressions() -> None:
2518
2518
FutureWarning ,
2519
2519
"'H' is deprecated" ,
2520
2520
lower = "2.1.99" ,
2521
- upper = "2.2 .99" ,
2521
+ upper = "2.3 .99" ,
2522
2522
upper_exception = ValueError ,
2523
2523
):
2524
2524
pd .date_range (start = "2021-12-01" , periods = 24 , freq = "H" )
@@ -2644,7 +2644,7 @@ class ReadCsvKwargs(TypedDict):
2644
2644
),
2645
2645
pd .DataFrame ,
2646
2646
)
2647
- if PD_LTE_22 :
2647
+ if PD_LTE_23 :
2648
2648
parse_dates_2 = {"combined_date" : ["Year" , "Month" , "Day" ]}
2649
2649
with pytest_warns_bounded (
2650
2650
FutureWarning ,
@@ -3098,7 +3098,7 @@ def test_frame_stack() -> None:
3098
3098
with pytest_warns_bounded (
3099
3099
FutureWarning ,
3100
3100
"The previous implementation of stack is deprecated" ,
3101
- upper = "2.2 .99" ,
3101
+ upper = "2.3 .99" ,
3102
3102
):
3103
3103
check (
3104
3104
assert_type (
@@ -3113,7 +3113,7 @@ def test_frame_stack() -> None:
3113
3113
),
3114
3114
pd .Series ,
3115
3115
)
3116
- if PD_LTE_22 :
3116
+ if PD_LTE_23 :
3117
3117
check (
3118
3118
assert_type (
3119
3119
df_multi_level_cols2 .stack (0 , future_stack = False ),
@@ -3133,19 +3133,17 @@ def test_frame_stack() -> None:
3133
3133
def test_frame_reindex () -> None :
3134
3134
# GH 84
3135
3135
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 )
3137
3137
3138
3138
3139
3139
def test_frame_reindex_like () -> None :
3140
3140
# GH 84
3141
3141
df = pd .DataFrame ({"a" : [1 , 2 , 3 ]}, index = [0 , 1 , 2 ])
3142
3142
other = pd .DataFrame ({"a" : [1 , 2 ]}, index = [1 , 0 ])
3143
-
3144
3143
with pytest_warns_bounded (
3145
3144
FutureWarning ,
3146
3145
"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" ,
3149
3147
):
3150
3148
check (
3151
3149
assert_type (
@@ -3277,7 +3275,7 @@ def test_groupby_result() -> None:
3277
3275
index , value = next (iterator )
3278
3276
assert_type ((index , value ), tuple [tuple , pd .DataFrame ])
3279
3277
3280
- if PD_LTE_22 :
3278
+ if PD_LTE_23 :
3281
3279
check (assert_type (index , tuple ), tuple , np .integer )
3282
3280
else :
3283
3281
check (assert_type (index , tuple ), tuple , int )
@@ -3389,7 +3387,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None:
3389
3387
with pytest_warns_bounded (
3390
3388
FutureWarning ,
3391
3389
"The default of observed=False is deprecated" ,
3392
- upper = "2.2 .99" ,
3390
+ upper = "2.3 .99" ,
3393
3391
):
3394
3392
categorical_index = pd .CategoricalIndex (df .a )
3395
3393
iterator2 = df .groupby (categorical_index ).__iter__ ()
@@ -3449,8 +3447,9 @@ def sum_mean(x: pd.DataFrame) -> float:
3449
3447
return x .sum ().mean ()
3450
3448
3451
3449
with pytest_warns_bounded (
3452
- DeprecationWarning ,
3450
+ FutureWarning ,
3453
3451
"DataFrameGroupBy.apply operated on the grouping columns." ,
3452
+ lower = "2.2.99" ,
3454
3453
upper = "2.99" ,
3455
3454
):
3456
3455
check (
@@ -3460,8 +3459,9 @@ def sum_mean(x: pd.DataFrame) -> float:
3460
3459
3461
3460
lfunc : Callable [[pd .DataFrame ], float ] = lambda x : x .sum ().mean ()
3462
3461
with pytest_warns_bounded (
3463
- DeprecationWarning ,
3462
+ FutureWarning ,
3464
3463
"DataFrameGroupBy.apply operated on the grouping columns." ,
3464
+ lower = "2.2.99" ,
3465
3465
upper = "2.99" ,
3466
3466
):
3467
3467
check (assert_type (df .groupby ("col1" ).apply (lfunc ), pd .Series ), pd .Series )
@@ -3470,8 +3470,9 @@ def sum_to_list(x: pd.DataFrame) -> list:
3470
3470
return x .sum ().tolist ()
3471
3471
3472
3472
with pytest_warns_bounded (
3473
- DeprecationWarning ,
3473
+ FutureWarning ,
3474
3474
"DataFrameGroupBy.apply operated on the grouping columns." ,
3475
+ lower = "2.2.99" ,
3475
3476
upper = "2.99" ,
3476
3477
):
3477
3478
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:
3480
3481
return x .sum ()
3481
3482
3482
3483
with pytest_warns_bounded (
3483
- DeprecationWarning ,
3484
+ FutureWarning ,
3484
3485
"DataFrameGroupBy.apply operated on the grouping columns." ,
3486
+ lower = "2.2.99" ,
3485
3487
upper = "2.99" ,
3486
3488
):
3487
3489
check (
@@ -3493,8 +3495,9 @@ def sample_to_df(x: pd.DataFrame) -> pd.DataFrame:
3493
3495
return x .sample ()
3494
3496
3495
3497
with pytest_warns_bounded (
3496
- DeprecationWarning ,
3498
+ FutureWarning ,
3497
3499
"DataFrameGroupBy.apply operated on the grouping columns." ,
3500
+ lower = "2.2.99" ,
3498
3501
upper = "2.99" ,
3499
3502
):
3500
3503
check (
@@ -3769,7 +3772,7 @@ def test_resample_150_changes() -> None:
3769
3772
FutureWarning ,
3770
3773
"'M' is deprecated" ,
3771
3774
lower = "2.1.99" ,
3772
- upper = "2.2. 99" ,
3775
+ upper = "2.99" ,
3773
3776
upper_exception = ValueError ,
3774
3777
):
3775
3778
frame .resample ("M" , group_keys = True )
@@ -3872,7 +3875,7 @@ def test_getattr_and_dataframe_groupby() -> None:
3872
3875
with pytest_warns_bounded (
3873
3876
FutureWarning ,
3874
3877
r"The provided callable <built-in function (min|max)> is currently using" ,
3875
- upper = "2.2 .99" ,
3878
+ upper = "2.3 .99" ,
3876
3879
):
3877
3880
check (assert_type (df .groupby ("col1" ).col3 .agg (min ), pd .Series ), pd .Series )
3878
3881
check (
@@ -4384,12 +4387,11 @@ def test_transpose() -> None:
4384
4387
df = pd .DataFrame ({"a" : [1 , 1 , 2 ], "b" : [4 , 5 , 6 ]})
4385
4388
check (assert_type (df .transpose (), pd .DataFrame ), pd .DataFrame )
4386
4389
check (assert_type (df .transpose (None ), pd .DataFrame ), pd .DataFrame )
4387
-
4388
4390
msg = "The copy keyword is deprecated and will be removed in a future"
4389
4391
with pytest_warns_bounded (
4390
4392
DeprecationWarning ,
4391
4393
msg ,
4392
- lower = "2.2 .99" ,
4394
+ lower = "2.3 .99" ,
4393
4395
):
4394
4396
check (assert_type (df .transpose (copy = True ), pd .DataFrame ), pd .DataFrame )
4395
4397
0 commit comments