@@ -72,13 +72,13 @@ def test_types_init() -> None:
72
72
73
73
def test_types_all () -> None :
74
74
df = pd .DataFrame ([[False , True ], [False , False ]], columns = ["col1" , "col2" ])
75
- check (assert_type (df .all (), "pd.Series[bool]" ), pd .Series , bool )
75
+ check (assert_type (df .all (), "pd.Series[bool]" ), pd .Series , np . bool_ )
76
76
check (assert_type (df .all (axis = None ), bool ), np .bool_ )
77
77
78
78
79
79
def test_types_any () -> None :
80
80
df = pd .DataFrame ([[False , True ], [False , False ]], columns = ["col1" , "col2" ])
81
- check (assert_type (df .any (), "pd.Series[bool]" ), pd .Series , bool )
81
+ check (assert_type (df .any (), "pd.Series[bool]" ), pd .Series , np . bool_ )
82
82
check (assert_type (df .any (axis = None ), bool ), np .bool_ )
83
83
84
84
@@ -496,7 +496,7 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
496
496
check (assert_type (df .apply (gethead , args = (4 ,)), pd .DataFrame ), pd .DataFrame )
497
497
498
498
# Check various return types for default result_type (None) with default axis (0)
499
- check (assert_type (df .apply (returns_scalar ), "pd.Series[int]" ), pd .Series , int )
499
+ check (assert_type (df .apply (returns_scalar ), "pd.Series[int]" ), pd .Series , np . int64 )
500
500
check (assert_type (df .apply (returns_series ), pd .DataFrame ), pd .DataFrame )
501
501
check (assert_type (df .apply (returns_listlike_of_3 ), pd .DataFrame ), pd .DataFrame )
502
502
check (assert_type (df .apply (returns_dict ), pd .Series ), pd .Series )
@@ -507,7 +507,7 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
507
507
# to pass a result_type of "expand" to a scalar return
508
508
assert_type (df .apply (returns_scalar , result_type = "expand" ), "pd.Series[int]" ),
509
509
pd .Series ,
510
- int ,
510
+ np . int64 ,
511
511
)
512
512
check (
513
513
assert_type (df .apply (returns_series , result_type = "expand" ), pd .DataFrame ),
@@ -530,7 +530,7 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
530
530
# to pass a result_type of "reduce" to a scalar return
531
531
assert_type (df .apply (returns_scalar , result_type = "reduce" ), "pd.Series[int]" ),
532
532
pd .Series ,
533
- int ,
533
+ np . int64 ,
534
534
)
535
535
check (
536
536
# Note that technically it does not make sense
@@ -548,7 +548,9 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
548
548
549
549
# Check various return types for default result_type (None) with axis=1
550
550
check (
551
- assert_type (df .apply (returns_scalar , axis = 1 ), "pd.Series[int]" ), pd .Series , int
551
+ assert_type (df .apply (returns_scalar , axis = 1 ), "pd.Series[int]" ),
552
+ pd .Series ,
553
+ np .int64 ,
552
554
)
553
555
check (assert_type (df .apply (returns_series , axis = 1 ), pd .DataFrame ), pd .DataFrame )
554
556
check (assert_type (df .apply (returns_listlike_of_3 , axis = 1 ), pd .Series ), pd .Series )
@@ -562,7 +564,7 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
562
564
df .apply (returns_scalar , axis = 1 , result_type = "expand" ), "pd.Series[int]"
563
565
),
564
566
pd .Series ,
565
- int ,
567
+ np . int64 ,
566
568
)
567
569
check (
568
570
assert_type (
@@ -589,7 +591,7 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
589
591
df .apply (returns_scalar , axis = 1 , result_type = "reduce" ), "pd.Series[int]"
590
592
),
591
593
pd .Series ,
592
- int ,
594
+ np . int64 ,
593
595
)
594
596
check (
595
597
# Note that technically it does not make sense
@@ -668,33 +670,35 @@ def gethead(s: pd.Series, y: int) -> pd.Series:
668
670
# Test various other positional/keyword argument combinations
669
671
# to ensure all overloads are supported
670
672
check (
671
- assert_type (df .apply (returns_scalar , axis = 0 ), "pd.Series[int]" ), pd .Series , int
673
+ assert_type (df .apply (returns_scalar , axis = 0 ), "pd.Series[int]" ),
674
+ pd .Series ,
675
+ np .int64 ,
672
676
)
673
677
check (
674
678
assert_type (
675
679
df .apply (returns_scalar , axis = 0 , result_type = None ), "pd.Series[int]"
676
680
),
677
681
pd .Series ,
678
- int ,
682
+ np . int64 ,
679
683
)
680
684
check (
681
685
assert_type (df .apply (returns_scalar , 0 , False , None ), "pd.Series[int]" ),
682
686
pd .Series ,
683
- int ,
687
+ np . int64 ,
684
688
)
685
689
check (
686
690
assert_type (
687
691
df .apply (returns_scalar , 0 , False , result_type = None ), "pd.Series[int]"
688
692
),
689
693
pd .Series ,
690
- int ,
694
+ np . int64 ,
691
695
)
692
696
check (
693
697
assert_type (
694
698
df .apply (returns_scalar , 0 , raw = False , result_type = None ), "pd.Series[int]"
695
699
),
696
700
pd .Series ,
697
- int ,
701
+ np . int64 ,
698
702
)
699
703
700
704
@@ -863,7 +867,7 @@ def test_types_groupby_methods() -> None:
863
867
check (
864
868
assert_type (df .groupby ("col1" ).value_counts (normalize = False ), "pd.Series[int]" ),
865
869
pd .Series ,
866
- int ,
870
+ np . int64 ,
867
871
)
868
872
check (
869
873
assert_type (
@@ -948,12 +952,12 @@ def test_types_groupby_any() -> None:
948
952
check (
949
953
assert_type (df .groupby ("col1" )["col2" ].any (), "pd.Series[bool]" ),
950
954
pd .Series ,
951
- bool ,
955
+ np . bool_ ,
952
956
)
953
957
check (
954
958
assert_type (df .groupby ("col1" )["col2" ].any (), "pd.Series[bool]" ),
955
959
pd .Series ,
956
- bool ,
960
+ np . bool_ ,
957
961
)
958
962
959
963
@@ -2277,7 +2281,7 @@ def test_series_groupby_and_value_counts() -> None:
2277
2281
)
2278
2282
c1 = df .groupby ("Animal" )["Max Speed" ].value_counts ()
2279
2283
c2 = df .groupby ("Animal" )["Max Speed" ].value_counts (normalize = True )
2280
- check (assert_type (c1 , "pd.Series[int]" ), pd .Series , int )
2284
+ check (assert_type (c1 , "pd.Series[int]" ), pd .Series , np . int64 )
2281
2285
check (assert_type (c2 , "pd.Series[float]" ), pd .Series , float )
2282
2286
2283
2287
0 commit comments