49
49
50
50
from tests import (
51
51
PD_LTE_22 ,
52
+ PD_LTE_23 ,
52
53
TYPE_CHECKING_INVALID_USAGE ,
53
54
check ,
54
55
ensure_clean ,
@@ -450,7 +451,7 @@ def test_types_drop_duplicates() -> None:
450
451
pd .DataFrame ,
451
452
)
452
453
453
- if not PD_LTE_22 :
454
+ if not PD_LTE_23 :
454
455
check (assert_type (df .drop_duplicates ({"AAA" }), pd .DataFrame ), pd .DataFrame )
455
456
check (
456
457
assert_type (df .drop_duplicates ({"AAA" : None }), pd .DataFrame ), pd .DataFrame
@@ -1602,7 +1603,7 @@ def wrapped_min(x: Any) -> Any:
1602
1603
with pytest_warns_bounded (
1603
1604
FutureWarning ,
1604
1605
r"The provided callable <built-in function (min|max)> is currently using" ,
1605
- upper = "2.2 .99" ,
1606
+ upper = "2.3 .99" ,
1606
1607
):
1607
1608
check (assert_type (df .groupby ("col1" )["col3" ].agg (min ), pd .Series ), pd .Series )
1608
1609
check (
@@ -1751,7 +1752,7 @@ def test_types_window() -> None:
1751
1752
with pytest_warns_bounded (
1752
1753
FutureWarning ,
1753
1754
r"The provided callable <built-in function (min|max)> is currently using" ,
1754
- upper = "2.2 .99" ,
1755
+ upper = "2.3 .99" ,
1755
1756
):
1756
1757
check (
1757
1758
assert_type (df .rolling (2 ).agg (max ), pd .DataFrame ),
@@ -1860,7 +1861,7 @@ def test_types_agg() -> None:
1860
1861
with pytest_warns_bounded (
1861
1862
FutureWarning ,
1862
1863
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" ,
1864
1865
):
1865
1866
check (assert_type (df .agg (min ), pd .Series ), pd .Series )
1866
1867
check (assert_type (df .agg ([min , max ]), pd .DataFrame ), pd .DataFrame )
@@ -1887,7 +1888,7 @@ def test_types_aggregate() -> None:
1887
1888
with pytest_warns_bounded (
1888
1889
FutureWarning ,
1889
1890
r"The provided callable <built-in function (min|max)> is currently using" ,
1890
- upper = "2.2 .99" ,
1891
+ upper = "2.3 .99" ,
1891
1892
):
1892
1893
check (assert_type (df .aggregate (min ), pd .Series ), pd .Series )
1893
1894
check (assert_type (df .aggregate ([min , max ]), pd .DataFrame ), pd .DataFrame )
@@ -2020,7 +2021,7 @@ def test_types_resample() -> None:
2020
2021
FutureWarning ,
2021
2022
"'M' is deprecated" ,
2022
2023
lower = "2.1.99" ,
2023
- upper = "2.2 .99" ,
2024
+ upper = "2.3 .99" ,
2024
2025
upper_exception = ValueError ,
2025
2026
):
2026
2027
df .resample ("M" , on = "date" )
@@ -2163,7 +2164,7 @@ def resampler_foo(resampler: Resampler[pd.DataFrame]) -> pd.DataFrame:
2163
2164
FutureWarning ,
2164
2165
"'M' is deprecated" ,
2165
2166
lower = "2.1.99" ,
2166
- upper = "2.2 .99" ,
2167
+ upper = "2.3 .99" ,
2167
2168
upper_exception = ValueError ,
2168
2169
):
2169
2170
(
@@ -2504,7 +2505,7 @@ def test_types_regressions() -> None:
2504
2505
tslist = list (pd .to_datetime (["2022-01-01" , "2022-01-02" ]))
2505
2506
check (assert_type (tslist , list [pd .Timestamp ]), list , pd .Timestamp )
2506
2507
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" ):
2508
2509
sseries + pd .Timedelta (1 , "d" )
2509
2510
2510
2511
check (
@@ -2518,7 +2519,7 @@ def test_types_regressions() -> None:
2518
2519
FutureWarning ,
2519
2520
"'H' is deprecated" ,
2520
2521
lower = "2.1.99" ,
2521
- upper = "2.2 .99" ,
2522
+ upper = "2.3 .99" ,
2522
2523
upper_exception = ValueError ,
2523
2524
):
2524
2525
pd .date_range (start = "2021-12-01" , periods = 24 , freq = "H" )
@@ -2644,7 +2645,7 @@ class ReadCsvKwargs(TypedDict):
2644
2645
),
2645
2646
pd .DataFrame ,
2646
2647
)
2647
- if PD_LTE_22 :
2648
+ if PD_LTE_23 :
2648
2649
parse_dates_2 = {"combined_date" : ["Year" , "Month" , "Day" ]}
2649
2650
with pytest_warns_bounded (
2650
2651
FutureWarning ,
@@ -3098,7 +3099,7 @@ def test_frame_stack() -> None:
3098
3099
with pytest_warns_bounded (
3099
3100
FutureWarning ,
3100
3101
"The previous implementation of stack is deprecated" ,
3101
- upper = "2.2 .99" ,
3102
+ upper = "2.3 .99" ,
3102
3103
):
3103
3104
check (
3104
3105
assert_type (
@@ -3113,7 +3114,7 @@ def test_frame_stack() -> None:
3113
3114
),
3114
3115
pd .Series ,
3115
3116
)
3116
- if PD_LTE_22 :
3117
+ if PD_LTE_23 :
3117
3118
check (
3118
3119
assert_type (
3119
3120
df_multi_level_cols2 .stack (0 , future_stack = False ),
@@ -3145,7 +3146,7 @@ def test_frame_reindex_like() -> None:
3145
3146
FutureWarning ,
3146
3147
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'" ,
3147
3148
lower = "2.2.99" ,
3148
- upper = "3.0 .99" ,
3149
+ upper = "2.2 .99" ,
3149
3150
):
3150
3151
check (
3151
3152
assert_type (
@@ -3277,7 +3278,7 @@ def test_groupby_result() -> None:
3277
3278
index , value = next (iterator )
3278
3279
assert_type ((index , value ), tuple [tuple , pd .DataFrame ])
3279
3280
3280
- if PD_LTE_22 :
3281
+ if PD_LTE_23 :
3281
3282
check (assert_type (index , tuple ), tuple , np .integer )
3282
3283
else :
3283
3284
check (assert_type (index , tuple ), tuple , int )
@@ -3389,7 +3390,7 @@ def test_groupby_result_for_ambiguous_indexes() -> None:
3389
3390
with pytest_warns_bounded (
3390
3391
FutureWarning ,
3391
3392
"The default of observed=False is deprecated" ,
3392
- upper = "2.2 .99" ,
3393
+ upper = "2.3 .99" ,
3393
3394
):
3394
3395
categorical_index = pd .CategoricalIndex (df .a )
3395
3396
iterator2 = df .groupby (categorical_index ).__iter__ ()
@@ -3448,41 +3449,72 @@ def test_groupby_apply() -> None:
3448
3449
def sum_mean (x : pd .DataFrame ) -> float :
3449
3450
return x .sum ().mean ()
3450
3451
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
+ ),
3455
3464
):
3456
3465
check (
3457
3466
assert_type (df .groupby ("col1" ).apply (sum_mean ), pd .Series ),
3458
3467
pd .Series ,
3459
3468
)
3460
3469
3461
3470
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
+ ),
3466
3482
):
3467
3483
check (assert_type (df .groupby ("col1" ).apply (lfunc ), pd .Series ), pd .Series )
3468
3484
3469
3485
def sum_to_list (x : pd .DataFrame ) -> list :
3470
3486
return x .sum ().tolist ()
3471
3487
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
+ ),
3476
3500
):
3477
3501
check (assert_type (df .groupby ("col1" ).apply (sum_to_list ), pd .Series ), pd .Series )
3478
3502
3479
3503
def sum_to_series (x : pd .DataFrame ) -> pd .Series :
3480
3504
return x .sum ()
3481
3505
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
+ ),
3486
3518
):
3487
3519
check (
3488
3520
assert_type (df .groupby ("col1" ).apply (sum_to_series ), pd .DataFrame ),
@@ -3492,10 +3524,18 @@ def sum_to_series(x: pd.DataFrame) -> pd.Series:
3492
3524
def sample_to_df (x : pd .DataFrame ) -> pd .DataFrame :
3493
3525
return x .sample ()
3494
3526
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
+ ),
3499
3539
):
3500
3540
check (
3501
3541
assert_type (
@@ -3769,7 +3809,7 @@ def test_resample_150_changes() -> None:
3769
3809
FutureWarning ,
3770
3810
"'M' is deprecated" ,
3771
3811
lower = "2.1.99" ,
3772
- upper = "2.2 .99" ,
3812
+ upper = "2.3 .99" ,
3773
3813
upper_exception = ValueError ,
3774
3814
):
3775
3815
frame .resample ("M" , group_keys = True )
@@ -3872,7 +3912,7 @@ def test_getattr_and_dataframe_groupby() -> None:
3872
3912
with pytest_warns_bounded (
3873
3913
FutureWarning ,
3874
3914
r"The provided callable <built-in function (min|max)> is currently using" ,
3875
- upper = "2.2 .99" ,
3915
+ upper = "2.3 .99" ,
3876
3916
):
3877
3917
check (assert_type (df .groupby ("col1" ).col3 .agg (min ), pd .Series ), pd .Series )
3878
3918
check (
@@ -4390,6 +4430,7 @@ def test_transpose() -> None:
4390
4430
DeprecationWarning ,
4391
4431
msg ,
4392
4432
lower = "2.2.99" ,
4433
+ upper = "2.2.99" ,
4393
4434
):
4394
4435
check (assert_type (df .transpose (copy = True ), pd .DataFrame ), pd .DataFrame )
4395
4436
0 commit comments