@@ -4050,7 +4050,7 @@ def _reindex_index(
4050
4050
new_index ,
4051
4051
method ,
4052
4052
copy : bool ,
4053
- level ,
4053
+ level : Level ,
4054
4054
fill_value = np .nan ,
4055
4055
limit = None ,
4056
4056
tolerance = None ,
@@ -4070,7 +4070,7 @@ def _reindex_columns(
4070
4070
new_columns ,
4071
4071
method ,
4072
4072
copy : bool ,
4073
- level ,
4073
+ level : Level ,
4074
4074
fill_value = None ,
4075
4075
limit = None ,
4076
4076
tolerance = None ,
@@ -4110,14 +4110,14 @@ def align(
4110
4110
self ,
4111
4111
other ,
4112
4112
join : str = "outer" ,
4113
- axis = None ,
4114
- level = None ,
4113
+ axis : Optional [ Axis ] = None ,
4114
+ level : Optional [ Level ] = None ,
4115
4115
copy : bool = True ,
4116
4116
fill_value = None ,
4117
4117
method : Optional [str ] = None ,
4118
4118
limit = None ,
4119
- fill_axis = 0 ,
4120
- broadcast_axis = None ,
4119
+ fill_axis : Axis = 0 ,
4120
+ broadcast_axis : Optional [ Axis ] = None ,
4121
4121
) -> DataFrame :
4122
4122
return super ().align (
4123
4123
other ,
@@ -4198,10 +4198,10 @@ def reindex(self, *args, **kwargs) -> DataFrame:
4198
4198
def drop (
4199
4199
self ,
4200
4200
labels = None ,
4201
- axis = 0 ,
4201
+ axis : Axis = 0 ,
4202
4202
index = None ,
4203
4203
columns = None ,
4204
- level = None ,
4204
+ level : Optional [ Level ] = None ,
4205
4205
inplace : bool = False ,
4206
4206
errors : str = "raise" ,
4207
4207
):
@@ -4474,7 +4474,7 @@ def fillna(
4474
4474
self ,
4475
4475
value = None ,
4476
4476
method : Optional [str ] = None ,
4477
- axis = None ,
4477
+ axis : Optional [ Axis ] = None ,
4478
4478
inplace : bool = False ,
4479
4479
limit = None ,
4480
4480
downcast = None ,
@@ -4587,7 +4587,7 @@ def _replace_columnwise(
4587
4587
4588
4588
@doc (NDFrame .shift , klass = _shared_doc_kwargs ["klass" ])
4589
4589
def shift (
4590
- self , periods = 1 , freq = None , axis = 0 , fill_value = lib .no_default
4590
+ self , periods = 1 , freq = None , axis : Axis = 0 , fill_value = lib .no_default
4591
4591
) -> DataFrame :
4592
4592
axis = self ._get_axis_number (axis )
4593
4593
@@ -5074,7 +5074,12 @@ def notnull(self) -> DataFrame:
5074
5074
return ~ self .isna ()
5075
5075
5076
5076
def dropna (
5077
- self , axis = 0 , how : str = "any" , thresh = None , subset = None , inplace : bool = False
5077
+ self ,
5078
+ axis : Axis = 0 ,
5079
+ how : str = "any" ,
5080
+ thresh = None ,
5081
+ subset = None ,
5082
+ inplace : bool = False ,
5078
5083
):
5079
5084
"""
5080
5085
Remove missing values.
@@ -5454,7 +5459,7 @@ def f(vals):
5454
5459
def sort_values ( # type: ignore[override]
5455
5460
self ,
5456
5461
by ,
5457
- axis = 0 ,
5462
+ axis : Axis = 0 ,
5458
5463
ascending = True ,
5459
5464
inplace : bool = False ,
5460
5465
kind : str = "quicksort" ,
@@ -5514,8 +5519,8 @@ def sort_values( # type: ignore[override]
5514
5519
5515
5520
def sort_index (
5516
5521
self ,
5517
- axis = 0 ,
5518
- level = None ,
5522
+ axis : Axis = 0 ,
5523
+ level : Optional [ Level ] = None ,
5519
5524
ascending : bool = True ,
5520
5525
inplace : bool = False ,
5521
5526
kind : str = "quicksort" ,
@@ -5932,7 +5937,7 @@ def nsmallest(self, n, columns, keep: str = "first") -> DataFrame:
5932
5937
self , n = n , keep = keep , columns = columns
5933
5938
).nsmallest ()
5934
5939
5935
- def swaplevel (self , i = - 2 , j = - 1 , axis = 0 ) -> DataFrame :
5940
+ def swaplevel (self , i : Axis = - 2 , j : Axis = - 1 , axis : Axis = 0 ) -> DataFrame :
5936
5941
"""
5937
5942
Swap levels i and j in a MultiIndex on a particular axis.
5938
5943
@@ -5963,7 +5968,7 @@ def swaplevel(self, i=-2, j=-1, axis=0) -> DataFrame:
5963
5968
result .columns = result .columns .swaplevel (i , j )
5964
5969
return result
5965
5970
5966
- def reorder_levels (self , order , axis = 0 ) -> DataFrame :
5971
+ def reorder_levels (self , order : Sequence [ Axis ] , axis : Axis = 0 ) -> DataFrame :
5967
5972
"""
5968
5973
Rearrange index levels using input order. May not drop or duplicate levels.
5969
5974
@@ -6726,8 +6731,8 @@ def update(
6726
6731
def groupby (
6727
6732
self ,
6728
6733
by = None ,
6729
- axis = 0 ,
6730
- level = None ,
6734
+ axis : Axis = 0 ,
6735
+ level : Optional [ Level ] = None ,
6731
6736
as_index : bool = True ,
6732
6737
sort : bool = True ,
6733
6738
group_keys : bool = True ,
@@ -7080,7 +7085,7 @@ def pivot_table(
7080
7085
observed = observed ,
7081
7086
)
7082
7087
7083
- def stack (self , level = - 1 , dropna : bool = True ):
7088
+ def stack (self , level : Level = - 1 , dropna : bool = True ):
7084
7089
"""
7085
7090
Stack the prescribed level(s) from columns to index.
7086
7091
@@ -7399,7 +7404,7 @@ def melt(
7399
7404
value_vars = None ,
7400
7405
var_name = None ,
7401
7406
value_name = "value" ,
7402
- col_level = None ,
7407
+ col_level : Optional [ Level ] = None ,
7403
7408
ignore_index = True ,
7404
7409
) -> DataFrame :
7405
7410
@@ -7607,7 +7612,7 @@ def _gotitem(
7607
7612
see_also = _agg_summary_and_see_also_doc ,
7608
7613
examples = _agg_examples_doc ,
7609
7614
)
7610
- def aggregate (self , func = None , axis = 0 , * args , ** kwargs ):
7615
+ def aggregate (self , func = None , axis : Axis = 0 , * args , ** kwargs ):
7611
7616
axis = self ._get_axis_number (axis )
7612
7617
7613
7618
relabeling , func , columns , order = reconstruct_func (func , ** kwargs )
@@ -7638,7 +7643,7 @@ def aggregate(self, func=None, axis=0, *args, **kwargs):
7638
7643
7639
7644
return result
7640
7645
7641
- def _aggregate (self , arg , axis = 0 , * args , ** kwargs ):
7646
+ def _aggregate (self , arg , axis : Axis = 0 , * args , ** kwargs ):
7642
7647
if axis == 1 :
7643
7648
# NDFrame.aggregate returns a tuple, and we need to transpose
7644
7649
# only result
@@ -7661,7 +7666,9 @@ def transform(
7661
7666
assert isinstance (result , DataFrame )
7662
7667
return result
7663
7668
7664
- def apply (self , func , axis = 0 , raw : bool = False , result_type = None , args = (), ** kwds ):
7669
+ def apply (
7670
+ self , func , axis : Axis = 0 , raw : bool = False , result_type = None , args = (), ** kwds
7671
+ ):
7665
7672
"""
7666
7673
Apply a function along an axis of the DataFrame.
7667
7674
@@ -8578,7 +8585,7 @@ def cov(
8578
8585
8579
8586
return self ._constructor (base_cov , index = idx , columns = cols )
8580
8587
8581
- def corrwith (self , other , axis = 0 , drop = False , method = "pearson" ) -> Series :
8588
+ def corrwith (self , other , axis : Axis = 0 , drop = False , method = "pearson" ) -> Series :
8582
8589
"""
8583
8590
Compute pairwise correlation.
8584
8591
@@ -8674,7 +8681,9 @@ def c(x):
8674
8681
# ----------------------------------------------------------------------
8675
8682
# ndarray-like stats methods
8676
8683
8677
- def count (self , axis = 0 , level = None , numeric_only : bool = False ):
8684
+ def count (
8685
+ self , axis : Axis = 0 , level : Optional [Level ] = None , numeric_only : bool = False
8686
+ ):
8678
8687
"""
8679
8688
Count non-NA cells for each column or row.
8680
8689
@@ -8778,7 +8787,7 @@ def count(self, axis=0, level=None, numeric_only: bool = False):
8778
8787
8779
8788
return result .astype ("int64" )
8780
8789
8781
- def _count_level (self , level , axis = 0 , numeric_only = False ):
8790
+ def _count_level (self , level : Level , axis : Axis = 0 , numeric_only = False ):
8782
8791
if numeric_only :
8783
8792
frame = self ._get_numeric_data ()
8784
8793
else :
@@ -8828,7 +8837,7 @@ def _reduce(
8828
8837
op ,
8829
8838
name : str ,
8830
8839
* ,
8831
- axis = 0 ,
8840
+ axis : Axis = 0 ,
8832
8841
skipna : bool = True ,
8833
8842
numeric_only : Optional [bool ] = None ,
8834
8843
filter_type = None ,
@@ -8936,7 +8945,7 @@ def _get_data() -> DataFrame:
8936
8945
result = self ._constructor_sliced (result , index = labels )
8937
8946
return result
8938
8947
8939
- def nunique (self , axis = 0 , dropna : bool = True ) -> Series :
8948
+ def nunique (self , axis : Axis = 0 , dropna : bool = True ) -> Series :
8940
8949
"""
8941
8950
Count distinct observations over requested axis.
8942
8951
@@ -8976,7 +8985,7 @@ def nunique(self, axis=0, dropna: bool = True) -> Series:
8976
8985
"""
8977
8986
return self .apply (Series .nunique , axis = axis , dropna = dropna )
8978
8987
8979
- def idxmin (self , axis = 0 , skipna : bool = True ) -> Series :
8988
+ def idxmin (self , axis : Axis = 0 , skipna : bool = True ) -> Series :
8980
8989
"""
8981
8990
Return index of first occurrence of minimum over requested axis.
8982
8991
@@ -9053,7 +9062,7 @@ def idxmin(self, axis=0, skipna: bool = True) -> Series:
9053
9062
result = [index [i ] if i >= 0 else np .nan for i in indices ]
9054
9063
return self ._constructor_sliced (result , index = self ._get_agg_axis (axis ))
9055
9064
9056
- def idxmax (self , axis = 0 , skipna : bool = True ) -> Series :
9065
+ def idxmax (self , axis : Axis = 0 , skipna : bool = True ) -> Series :
9057
9066
"""
9058
9067
Return index of first occurrence of maximum over requested axis.
9059
9068
@@ -9142,7 +9151,7 @@ def _get_agg_axis(self, axis_num: int) -> Index:
9142
9151
raise ValueError (f"Axis must be 0 or 1 (got { repr (axis_num )} )" )
9143
9152
9144
9153
def mode (
9145
- self , axis = 0 , numeric_only : bool = False , dropna : bool = True
9154
+ self , axis : Axis = 0 , numeric_only : bool = False , dropna : bool = True
9146
9155
) -> DataFrame :
9147
9156
"""
9148
9157
Get the mode(s) of each element along the selected axis.
@@ -9231,7 +9240,11 @@ def f(s):
9231
9240
return data .apply (f , axis = axis )
9232
9241
9233
9242
def quantile (
9234
- self , q = 0.5 , axis = 0 , numeric_only : bool = True , interpolation : str = "linear"
9243
+ self ,
9244
+ q = 0.5 ,
9245
+ axis : Axis = 0 ,
9246
+ numeric_only : bool = True ,
9247
+ interpolation : str = "linear" ,
9235
9248
):
9236
9249
"""
9237
9250
Return values at the given quantile over requested axis.
0 commit comments