48
48
from pandas ._typing import Scalar
49
49
50
50
from tests import (
51
- PD_LTE_22 ,
52
51
PD_LTE_23 ,
53
52
TYPE_CHECKING_INVALID_USAGE ,
54
53
check ,
@@ -1542,21 +1541,6 @@ def test_types_groupby() -> None:
1542
1541
assert_type (df .groupby (by = ["col1" , "col2" ]).nunique (), pd .DataFrame ),
1543
1542
pd .DataFrame ,
1544
1543
)
1545
- with pytest_warns_bounded (
1546
- FutureWarning ,
1547
- "(The provided callable <built-in function sum> is currently using|The behavior of DataFrame.sum with)" ,
1548
- upper = "2.2.99" ,
1549
- ):
1550
- with pytest_warns_bounded (
1551
- DeprecationWarning ,
1552
- "DataFrameGroupBy.apply operated on the grouping columns" ,
1553
- upper = "2.2.99" ,
1554
- ):
1555
- if PD_LTE_22 :
1556
- check (
1557
- assert_type (df .groupby (by = "col1" ).apply (sum ), pd .DataFrame ),
1558
- pd .DataFrame ,
1559
- )
1560
1544
check (assert_type (df .groupby ("col1" ).transform ("sum" ), pd .DataFrame ), pd .DataFrame )
1561
1545
s1 = df .set_index ("col1" )["col2" ]
1562
1546
check (assert_type (s1 , pd .Series ), pd .Series )
@@ -3134,19 +3118,17 @@ def test_frame_stack() -> None:
3134
3118
def test_frame_reindex () -> None :
3135
3119
# GH 84
3136
3120
df = pd .DataFrame ({"a" : [1 , 2 , 3 ]}, index = [0 , 1 , 2 ])
3137
- df .reindex ([2 , 1 , 0 ])
3121
+ check ( assert_type ( df .reindex ([2 , 1 , 0 ]), pd . DataFrame ), pd . DataFrame )
3138
3122
3139
3123
3140
3124
def test_frame_reindex_like () -> None :
3141
3125
# GH 84
3142
3126
df = pd .DataFrame ({"a" : [1 , 2 , 3 ]}, index = [0 , 1 , 2 ])
3143
3127
other = pd .DataFrame ({"a" : [1 , 2 ]}, index = [1 , 0 ])
3144
-
3145
3128
with pytest_warns_bounded (
3146
3129
FutureWarning ,
3147
3130
"the 'method' keyword is deprecated and will be removed in a future version. Please take steps to stop the use of 'method'" ,
3148
- lower = "2.2.99" ,
3149
- upper = "2.2.99" ,
3131
+ lower = "2.3.0" ,
3150
3132
):
3151
3133
check (
3152
3134
assert_type (
@@ -3449,72 +3431,45 @@ def test_groupby_apply() -> None:
3449
3431
def sum_mean (x : pd .DataFrame ) -> float :
3450
3432
return x .sum ().mean ()
3451
3433
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
- ),
3434
+ with pytest_warns_bounded (
3435
+ FutureWarning ,
3436
+ "DataFrameGroupBy.apply operated on the grouping columns." ,
3437
+ lower = "2.2.99" ,
3438
+ upper = "2.3.99" ,
3464
3439
):
3465
3440
check (
3466
3441
assert_type (df .groupby ("col1" ).apply (sum_mean ), pd .Series ),
3467
3442
pd .Series ,
3468
3443
)
3469
3444
3470
3445
lfunc : Callable [[pd .DataFrame ], float ] = lambda x : x .sum ().mean ()
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
- ),
3446
+ with pytest_warns_bounded (
3447
+ FutureWarning ,
3448
+ "DataFrameGroupBy.apply operated on the grouping columns." ,
3449
+ lower = "2.2.99" ,
3450
+ upper = "2.99.99" ,
3482
3451
):
3483
3452
check (assert_type (df .groupby ("col1" ).apply (lfunc ), pd .Series ), pd .Series )
3484
3453
3485
3454
def sum_to_list (x : pd .DataFrame ) -> list :
3486
3455
return x .sum ().tolist ()
3487
3456
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
- ),
3457
+ with pytest_warns_bounded (
3458
+ FutureWarning ,
3459
+ "DataFrameGroupBy.apply operated on the grouping columns." ,
3460
+ lower = "2.2.99" ,
3461
+ upper = "2.3.99" ,
3500
3462
):
3501
3463
check (assert_type (df .groupby ("col1" ).apply (sum_to_list ), pd .Series ), pd .Series )
3502
3464
3503
3465
def sum_to_series (x : pd .DataFrame ) -> pd .Series :
3504
3466
return x .sum ()
3505
3467
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
- ),
3468
+ with pytest_warns_bounded (
3469
+ FutureWarning ,
3470
+ "DataFrameGroupBy.apply operated on the grouping columns." ,
3471
+ lower = "2.2.99" ,
3472
+ upper = "2.3.99" ,
3518
3473
):
3519
3474
check (
3520
3475
assert_type (df .groupby ("col1" ).apply (sum_to_series ), pd .DataFrame ),
@@ -3524,18 +3479,11 @@ def sum_to_series(x: pd.DataFrame) -> pd.Series:
3524
3479
def sample_to_df (x : pd .DataFrame ) -> pd .DataFrame :
3525
3480
return x .sample ()
3526
3481
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
- ),
3482
+ with pytest_warns_bounded (
3483
+ FutureWarning ,
3484
+ "DataFrameGroupBy.apply operated on the grouping columns." ,
3485
+ lower = "2.2.99" ,
3486
+ upper = "2.3.99" ,
3539
3487
):
3540
3488
check (
3541
3489
assert_type (
@@ -4424,13 +4372,12 @@ def test_transpose() -> None:
4424
4372
df = pd .DataFrame ({"a" : [1 , 1 , 2 ], "b" : [4 , 5 , 6 ]})
4425
4373
check (assert_type (df .transpose (), pd .DataFrame ), pd .DataFrame )
4426
4374
check (assert_type (df .transpose (None ), pd .DataFrame ), pd .DataFrame )
4427
-
4428
4375
msg = "The copy keyword is deprecated and will be removed in a future"
4429
4376
with pytest_warns_bounded (
4430
4377
DeprecationWarning ,
4431
4378
msg ,
4432
- lower = "2.2 .99" ,
4433
- upper = "2.2.99 " ,
4379
+ lower = "2.3 .99" ,
4380
+ upper = "3.0.0 " ,
4434
4381
):
4435
4382
check (assert_type (df .transpose (copy = True ), pd .DataFrame ), pd .DataFrame )
4436
4383
0 commit comments