@@ -1435,7 +1435,7 @@ def to_numpy(
1435
1435
1436
1436
return result
1437
1437
1438
- def to_dict (self , orient = "dict" , into = dict ):
1438
+ def to_dict (self , orient : str = "dict" , into = dict ):
1439
1439
"""
1440
1440
Convert the DataFrame to a dictionary.
1441
1441
@@ -1610,15 +1610,15 @@ def to_dict(self, orient="dict", into=dict):
1610
1610
1611
1611
def to_gbq (
1612
1612
self ,
1613
- destination_table ,
1614
- project_id = None ,
1613
+ destination_table : str ,
1614
+ project_id : Optional [ str ] = None ,
1615
1615
chunksize = None ,
1616
- reauth = False ,
1617
- if_exists = "fail" ,
1618
- auth_local_webserver = False ,
1616
+ reauth : bool = False ,
1617
+ if_exists : str = "fail" ,
1618
+ auth_local_webserver : bool = False ,
1619
1619
table_schema = None ,
1620
- location = None ,
1621
- progress_bar = True ,
1620
+ location : Optional [ str ] = None ,
1621
+ progress_bar : bool = True ,
1622
1622
credentials = None ,
1623
1623
) -> None :
1624
1624
"""
@@ -1723,7 +1723,7 @@ def from_records(
1723
1723
index = None ,
1724
1724
exclude = None ,
1725
1725
columns = None ,
1726
- coerce_float = False ,
1726
+ coerce_float : bool = False ,
1727
1727
nrows = None ,
1728
1728
) -> DataFrame :
1729
1729
"""
@@ -2488,7 +2488,7 @@ def to_html(
2488
2488
max_rows = None ,
2489
2489
max_cols = None ,
2490
2490
show_dimensions = False ,
2491
- decimal = "." ,
2491
+ decimal : str = "." ,
2492
2492
bold_rows = True ,
2493
2493
classes = None ,
2494
2494
escape = True ,
@@ -3321,7 +3321,7 @@ def _box_col_values(self, values, loc: int) -> Series:
3321
3321
# ----------------------------------------------------------------------
3322
3322
# Unsorted
3323
3323
3324
- def query (self , expr , inplace = False , ** kwargs ):
3324
+ def query (self , expr : str , inplace : bool = False , ** kwargs ):
3325
3325
"""
3326
3326
Query the columns of a DataFrame with a boolean expression.
3327
3327
@@ -3485,7 +3485,7 @@ def query(self, expr, inplace=False, **kwargs):
3485
3485
else :
3486
3486
return result
3487
3487
3488
- def eval (self , expr , inplace = False , ** kwargs ):
3488
+ def eval (self , expr : str , inplace : bool = False , ** kwargs ):
3489
3489
"""
3490
3490
Evaluate a string describing operations on DataFrame columns.
3491
3491
@@ -3742,7 +3742,7 @@ def extract_unique_dtypes_from_dtypes_set(
3742
3742
3743
3743
return self .iloc [:, keep_these .values ]
3744
3744
3745
- def insert (self , loc , column , value , allow_duplicates = False ) -> None :
3745
+ def insert (self , loc , column , value , allow_duplicates : bool = False ) -> None :
3746
3746
"""
3747
3747
Insert column into DataFrame at specified location.
3748
3748
@@ -3856,7 +3856,7 @@ def assign(self, **kwargs) -> DataFrame:
3856
3856
data [k ] = com .apply_if_callable (v , data )
3857
3857
return data
3858
3858
3859
- def _sanitize_column (self , key , value , broadcast = True ):
3859
+ def _sanitize_column (self , key , value , broadcast : bool = True ):
3860
3860
"""
3861
3861
Ensures new columns (which go into the BlockManager as new blocks) are
3862
3862
always copied and converted into an array.
@@ -4049,7 +4049,7 @@ def _reindex_index(
4049
4049
self ,
4050
4050
new_index ,
4051
4051
method ,
4052
- copy ,
4052
+ copy : bool ,
4053
4053
level ,
4054
4054
fill_value = np .nan ,
4055
4055
limit = None ,
@@ -4069,7 +4069,7 @@ def _reindex_columns(
4069
4069
self ,
4070
4070
new_columns ,
4071
4071
method ,
4072
- copy ,
4072
+ copy : bool ,
4073
4073
level ,
4074
4074
fill_value = None ,
4075
4075
limit = None ,
@@ -4085,7 +4085,7 @@ def _reindex_columns(
4085
4085
allow_dups = False ,
4086
4086
)
4087
4087
4088
- def _reindex_multi (self , axes , copy , fill_value ) -> DataFrame :
4088
+ def _reindex_multi (self , axes , copy : bool , fill_value ) -> DataFrame :
4089
4089
"""
4090
4090
We are guaranteed non-Nones in the axes.
4091
4091
"""
@@ -4109,12 +4109,12 @@ def _reindex_multi(self, axes, copy, fill_value) -> DataFrame:
4109
4109
def align (
4110
4110
self ,
4111
4111
other ,
4112
- join = "outer" ,
4112
+ join : str = "outer" ,
4113
4113
axis = None ,
4114
4114
level = None ,
4115
- copy = True ,
4115
+ copy : bool = True ,
4116
4116
fill_value = None ,
4117
- method = None ,
4117
+ method : Optional [ str ] = None ,
4118
4118
limit = None ,
4119
4119
fill_axis = 0 ,
4120
4120
broadcast_axis = None ,
@@ -4202,8 +4202,8 @@ def drop(
4202
4202
index = None ,
4203
4203
columns = None ,
4204
4204
level = None ,
4205
- inplace = False ,
4206
- errors = "raise" ,
4205
+ inplace : bool = False ,
4206
+ errors : str = "raise" ,
4207
4207
):
4208
4208
"""
4209
4209
Drop specified labels from rows or columns.
@@ -4473,9 +4473,9 @@ def rename(
4473
4473
def fillna (
4474
4474
self ,
4475
4475
value = None ,
4476
- method = None ,
4476
+ method : Optional [ str ] = None ,
4477
4477
axis = None ,
4478
- inplace = False ,
4478
+ inplace : bool = False ,
4479
4479
limit = None ,
4480
4480
downcast = None ,
4481
4481
) -> Optional [DataFrame ]:
@@ -4536,10 +4536,10 @@ def replace(
4536
4536
self ,
4537
4537
to_replace = None ,
4538
4538
value = None ,
4539
- inplace = False ,
4539
+ inplace : bool = False ,
4540
4540
limit = None ,
4541
- regex = False ,
4542
- method = "pad" ,
4541
+ regex : bool = False ,
4542
+ method : str = "pad" ,
4543
4543
):
4544
4544
return super ().replace (
4545
4545
to_replace = to_replace ,
@@ -4619,7 +4619,12 @@ def shift(
4619
4619
)
4620
4620
4621
4621
def set_index (
4622
- self , keys , drop = True , append = False , inplace = False , verify_integrity = False
4622
+ self ,
4623
+ keys ,
4624
+ drop : bool = True ,
4625
+ append : bool = False ,
4626
+ inplace : bool = False ,
4627
+ verify_integrity : bool = False ,
4623
4628
):
4624
4629
"""
4625
4630
Set the DataFrame index using existing columns.
@@ -5068,7 +5073,9 @@ def notna(self) -> DataFrame:
5068
5073
def notnull (self ) -> DataFrame :
5069
5074
return ~ self .isna ()
5070
5075
5071
- def dropna (self , axis = 0 , how = "any" , thresh = None , subset = None , inplace = False ):
5076
+ def dropna (
5077
+ self , axis = 0 , how : str = "any" , thresh = None , subset = None , inplace : bool = False
5078
+ ):
5072
5079
"""
5073
5080
Remove missing values.
5074
5081
@@ -5449,10 +5456,10 @@ def sort_values( # type: ignore[override]
5449
5456
by ,
5450
5457
axis = 0 ,
5451
5458
ascending = True ,
5452
- inplace = False ,
5453
- kind = "quicksort" ,
5454
- na_position = "last" ,
5455
- ignore_index = False ,
5459
+ inplace : bool = False ,
5460
+ kind : str = "quicksort" ,
5461
+ na_position : str = "last" ,
5462
+ ignore_index : bool = False ,
5456
5463
key : ValueKeyFunc = None ,
5457
5464
):
5458
5465
inplace = validate_bool_kwarg (inplace , "inplace" )
@@ -5714,7 +5721,7 @@ def value_counts(
5714
5721
5715
5722
return counts
5716
5723
5717
- def nlargest (self , n , columns , keep = "first" ) -> DataFrame :
5724
+ def nlargest (self , n , columns , keep : str = "first" ) -> DataFrame :
5718
5725
"""
5719
5726
Return the first `n` rows ordered by `columns` in descending order.
5720
5727
@@ -5823,7 +5830,7 @@ def nlargest(self, n, columns, keep="first") -> DataFrame:
5823
5830
"""
5824
5831
return algorithms .SelectNFrame (self , n = n , keep = keep , columns = columns ).nlargest ()
5825
5832
5826
- def nsmallest (self , n , columns , keep = "first" ) -> DataFrame :
5833
+ def nsmallest (self , n , columns , keep : str = "first" ) -> DataFrame :
5827
5834
"""
5828
5835
Return the first `n` rows ordered by `columns` in ascending order.
5829
5836
@@ -6247,7 +6254,7 @@ def compare(
6247
6254
)
6248
6255
6249
6256
def combine (
6250
- self , other : DataFrame , func , fill_value = None , overwrite = True
6257
+ self , other : DataFrame , func , fill_value = None , overwrite : bool = True
6251
6258
) -> DataFrame :
6252
6259
"""
6253
6260
Perform column-wise combine with another DataFrame.
@@ -6475,7 +6482,12 @@ def combiner(x, y):
6475
6482
return self .combine (other , combiner , overwrite = False )
6476
6483
6477
6484
def update (
6478
- self , other , join = "left" , overwrite = True , filter_func = None , errors = "ignore"
6485
+ self ,
6486
+ other ,
6487
+ join : str = "left" ,
6488
+ overwrite : bool = True ,
6489
+ filter_func = None ,
6490
+ errors : str = "ignore" ,
6479
6491
) -> None :
6480
6492
"""
6481
6493
Modify in place using non-NA values from another DataFrame.
@@ -7068,7 +7080,7 @@ def pivot_table(
7068
7080
observed = observed ,
7069
7081
)
7070
7082
7071
- def stack (self , level = - 1 , dropna = True ):
7083
+ def stack (self , level = - 1 , dropna : bool = True ):
7072
7084
"""
7073
7085
Stack the prescribed level(s) from columns to index.
7074
7086
@@ -7649,7 +7661,7 @@ def transform(
7649
7661
assert isinstance (result , DataFrame )
7650
7662
return result
7651
7663
7652
- def apply (self , func , axis = 0 , raw = False , result_type = None , args = (), ** kwds ):
7664
+ def apply (self , func , axis = 0 , raw : bool = False , result_type = None , args = (), ** kwds ):
7653
7665
"""
7654
7666
Apply a function along an axis of the DataFrame.
7655
7667
@@ -7874,7 +7886,11 @@ def infer(x):
7874
7886
# Merging / joining methods
7875
7887
7876
7888
def append (
7877
- self , other , ignore_index = False , verify_integrity = False , sort = False
7889
+ self ,
7890
+ other ,
7891
+ ignore_index : bool = False ,
7892
+ verify_integrity : bool = False ,
7893
+ sort : bool = False ,
7878
7894
) -> DataFrame :
7879
7895
"""
7880
7896
Append rows of `other` to the end of caller, returning a new object.
@@ -8015,7 +8031,13 @@ def append(
8015
8031
).__finalize__ (self , method = "append" )
8016
8032
8017
8033
def join (
8018
- self , other , on = None , how = "left" , lsuffix = "" , rsuffix = "" , sort = False
8034
+ self ,
8035
+ other ,
8036
+ on = None ,
8037
+ how : str = "left" ,
8038
+ lsuffix : str = "" ,
8039
+ rsuffix : str = "" ,
8040
+ sort : bool = False ,
8019
8041
) -> DataFrame :
8020
8042
"""
8021
8043
Join columns of another DataFrame.
@@ -8652,7 +8674,7 @@ def c(x):
8652
8674
# ----------------------------------------------------------------------
8653
8675
# ndarray-like stats methods
8654
8676
8655
- def count (self , axis = 0 , level = None , numeric_only = False ):
8677
+ def count (self , axis = 0 , level = None , numeric_only : bool = False ):
8656
8678
"""
8657
8679
Count non-NA cells for each column or row.
8658
8680
@@ -8807,8 +8829,8 @@ def _reduce(
8807
8829
name : str ,
8808
8830
* ,
8809
8831
axis = 0 ,
8810
- skipna = True ,
8811
- numeric_only = None ,
8832
+ skipna : bool = True ,
8833
+ numeric_only : Optional [ bool ] = None ,
8812
8834
filter_type = None ,
8813
8835
** kwds ,
8814
8836
):
@@ -8914,7 +8936,7 @@ def _get_data() -> DataFrame:
8914
8936
result = self ._constructor_sliced (result , index = labels )
8915
8937
return result
8916
8938
8917
- def nunique (self , axis = 0 , dropna = True ) -> Series :
8939
+ def nunique (self , axis = 0 , dropna : bool = True ) -> Series :
8918
8940
"""
8919
8941
Count distinct observations over requested axis.
8920
8942
@@ -8954,7 +8976,7 @@ def nunique(self, axis=0, dropna=True) -> Series:
8954
8976
"""
8955
8977
return self .apply (Series .nunique , axis = axis , dropna = dropna )
8956
8978
8957
- def idxmin (self , axis = 0 , skipna = True ) -> Series :
8979
+ def idxmin (self , axis = 0 , skipna : bool = True ) -> Series :
8958
8980
"""
8959
8981
Return index of first occurrence of minimum over requested axis.
8960
8982
@@ -9031,7 +9053,7 @@ def idxmin(self, axis=0, skipna=True) -> Series:
9031
9053
result = [index [i ] if i >= 0 else np .nan for i in indices ]
9032
9054
return self ._constructor_sliced (result , index = self ._get_agg_axis (axis ))
9033
9055
9034
- def idxmax (self , axis = 0 , skipna = True ) -> Series :
9056
+ def idxmax (self , axis = 0 , skipna : bool = True ) -> Series :
9035
9057
"""
9036
9058
Return index of first occurrence of maximum over requested axis.
9037
9059
@@ -9119,7 +9141,9 @@ def _get_agg_axis(self, axis_num: int) -> Index:
9119
9141
else :
9120
9142
raise ValueError (f"Axis must be 0 or 1 (got { repr (axis_num )} )" )
9121
9143
9122
- def mode (self , axis = 0 , numeric_only = False , dropna = True ) -> DataFrame :
9144
+ def mode (
9145
+ self , axis = 0 , numeric_only : bool = False , dropna : bool = True
9146
+ ) -> DataFrame :
9123
9147
"""
9124
9148
Get the mode(s) of each element along the selected axis.
9125
9149
@@ -9206,7 +9230,9 @@ def f(s):
9206
9230
9207
9231
return data .apply (f , axis = axis )
9208
9232
9209
- def quantile (self , q = 0.5 , axis = 0 , numeric_only = True , interpolation = "linear" ):
9233
+ def quantile (
9234
+ self , q = 0.5 , axis = 0 , numeric_only : bool = True , interpolation : str = "linear"
9235
+ ):
9210
9236
"""
9211
9237
Return values at the given quantile over requested axis.
9212
9238
0 commit comments