Skip to content

Commit 867dc94

Browse files
authored
DOC: boolean->bool, string->str in docstrings (#40698)
1 parent 244db51 commit 867dc94

39 files changed

+82
-82
lines changed

pandas/_libs/algos.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,10 @@ def rank_1d(
933933
* max: highest rank in group
934934
* first: ranks assigned in order they appear in the array
935935
* dense: like 'min', but rank always increases by 1 between groups
936-
ascending : boolean, default True
936+
ascending : bool, default True
937937
False for ranks by high (1) to low (N)
938938
na_option : {'keep', 'top', 'bottom'}, default 'keep'
939-
pct : boolean, default False
939+
pct : bool, default False
940940
Compute percentage rank of data within each group
941941
na_option : {'keep', 'top', 'bottom'}, default 'keep'
942942
* keep: leave NA values where they are

pandas/_libs/groupby.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,9 @@ def group_any_all(uint8_t[::1] out,
402402
ordering matching up to the corresponding record in `values`
403403
values : array containing the truth value of each element
404404
mask : array indicating whether a value is na or not
405-
val_test : str {'any', 'all'}
405+
val_test : {'any', 'all'}
406406
String object dictating whether to use any or all truth testing
407-
skipna : boolean
407+
skipna : bool
408408
Flag to ignore nan values during truth testing
409409
410410
Notes
@@ -1083,10 +1083,10 @@ def group_rank(float64_t[:, ::1] out,
10831083
* max: highest rank in group
10841084
* first: ranks assigned in order they appear in the array
10851085
* dense: like 'min', but rank always increases by 1 between groups
1086-
ascending : boolean, default True
1086+
ascending : bool, default True
10871087
False for ranks by high (1) to low (N)
10881088
na_option : {'keep', 'top', 'bottom'}, default 'keep'
1089-
pct : boolean, default False
1089+
pct : bool, default False
10901090
Compute percentage rank of data within each group
10911091
na_option : {'keep', 'top', 'bottom'}, default 'keep'
10921092
* keep: leave NA values where they are

pandas/_libs/hashtable_class_helper.pxi.in

+9-9
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,15 @@ cdef class {{name}}HashTable(HashTable):
523523
any value "val" satisfying val != val is considered missing.
524524
If na_value is not None, then _additionally_, any value "val"
525525
satisfying val == na_value is considered missing.
526-
ignore_na : boolean, default False
526+
ignore_na : bool, default False
527527
Whether NA-values should be ignored for calculating the uniques. If
528528
True, the labels corresponding to missing values will be set to
529529
na_sentinel.
530530
mask : ndarray[bool], optional
531531
If not None, the mask is used as indicator for missing values
532532
(True = missing, False = valid) instead of `na_value` or
533533
condition "val != val".
534-
return_inverse : boolean, default False
534+
return_inverse : bool, default False
535535
Whether the mapping of the original array values to their location
536536
in the vector of uniques should be returned.
537537

@@ -625,7 +625,7 @@ cdef class {{name}}HashTable(HashTable):
625625
----------
626626
values : ndarray[{{dtype}}]
627627
Array of values of which unique will be calculated
628-
return_inverse : boolean, default False
628+
return_inverse : bool, default False
629629
Whether the mapping of the original array values to their location
630630
in the vector of uniques should be returned.
631631

@@ -906,11 +906,11 @@ cdef class StringHashTable(HashTable):
906906
that is not a string is considered missing. If na_value is
907907
not None, then _additionally_ any value "val" satisfying
908908
val == na_value is considered missing.
909-
ignore_na : boolean, default False
909+
ignore_na : bool, default False
910910
Whether NA-values should be ignored for calculating the uniques. If
911911
True, the labels corresponding to missing values will be set to
912912
na_sentinel.
913-
return_inverse : boolean, default False
913+
return_inverse : bool, default False
914914
Whether the mapping of the original array values to their location
915915
in the vector of uniques should be returned.
916916

@@ -998,7 +998,7 @@ cdef class StringHashTable(HashTable):
998998
----------
999999
values : ndarray[object]
10001000
Array of values of which unique will be calculated
1001-
return_inverse : boolean, default False
1001+
return_inverse : bool, default False
10021002
Whether the mapping of the original array values to their location
10031003
in the vector of uniques should be returned.
10041004

@@ -1181,11 +1181,11 @@ cdef class PyObjectHashTable(HashTable):
11811181
any value "val" satisfying val != val is considered missing.
11821182
If na_value is not None, then _additionally_, any value "val"
11831183
satisfying val == na_value is considered missing.
1184-
ignore_na : boolean, default False
1184+
ignore_na : bool, default False
11851185
Whether NA-values should be ignored for calculating the uniques. If
11861186
True, the labels corresponding to missing values will be set to
11871187
na_sentinel.
1188-
return_inverse : boolean, default False
1188+
return_inverse : bool, default False
11891189
Whether the mapping of the original array values to their location
11901190
in the vector of uniques should be returned.
11911191

@@ -1251,7 +1251,7 @@ cdef class PyObjectHashTable(HashTable):
12511251
----------
12521252
values : ndarray[object]
12531253
Array of values of which unique will be calculated
1254-
return_inverse : boolean, default False
1254+
return_inverse : bool, default False
12551255
Whether the mapping of the original array values to their location
12561256
in the vector of uniques should be returned.
12571257

pandas/_libs/reshape.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ def unstack(reshape_t[:, :] values, const uint8_t[:] mask,
4848
Parameters
4949
----------
5050
values : typed ndarray
51-
mask : boolean ndarray
51+
mask : np.ndarray[bool]
5252
stride : int
5353
length : int
5454
width : int
5555
new_values : typed ndarray
5656
result array
57-
new_mask : boolean ndarray
57+
new_mask : np.ndarray[bool]
5858
result mask
5959
"""
6060
cdef:

pandas/_libs/tslibs/conversion.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def ensure_timedelta64ns(arr: ndarray, copy: bool=True):
267267
Parameters
268268
----------
269269
arr : ndarray
270-
copy : boolean, default True
270+
copy : bool, default True
271271
272272
Returns
273273
-------

pandas/_libs/tslibs/fields.pyx

+3-3
Original file line numberDiff line numberDiff line change
@@ -635,9 +635,9 @@ def get_locale_names(name_type: str, locale: object = None):
635635
636636
Parameters
637637
----------
638-
name_type : string, attribute of LocaleTime() in which to return localized
639-
names
640-
locale : string
638+
name_type : str
639+
Attribute of LocaleTime() in which to return localized names.
640+
locale : str
641641
642642
Returns
643643
-------

pandas/_libs/tslibs/timedeltas.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ cdef inline int64_t timedelta_as_neg(int64_t value, bint neg):
540540
Parameters
541541
----------
542542
value : int64_t of the timedelta value
543-
neg : boolean if the a negative value
543+
neg : bool if the a negative value
544544
"""
545545
if neg:
546546
return -value

pandas/_testing/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ def get_op_from_name(op_name: str) -> Callable:
952952
953953
Parameters
954954
----------
955-
op_name : string
955+
op_name : str
956956
The op name, in form of "add" or "__add__".
957957
958958
Returns

pandas/core/algorithms.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ def mode(values, dropna: bool = True) -> Series:
959959
----------
960960
values : array-like
961961
Array over which to check for duplicate values.
962-
dropna : boolean, default True
962+
dropna : bool, default True
963963
Don't consider counts of NaN/NaT.
964964
965965
.. versionadded:: 0.24.0
@@ -1025,9 +1025,9 @@ def rank(
10251025
- ``keep``: rank each NaN value with a NaN ranking
10261026
- ``top``: replace each NaN with either +/- inf so that they
10271027
there are ranked at the top
1028-
ascending : boolean, default True
1028+
ascending : bool, default True
10291029
Whether or not the elements should be ranked in ascending order.
1030-
pct : boolean, default False
1030+
pct : bool, default False
10311031
Whether or not to the display the returned rankings in integer form
10321032
(e.g. 1, 2, 3) or in percentile form (e.g. 0.333..., 0.666..., 1).
10331033
"""

pandas/core/array_algos/take.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def take_nd(
7676
Axis to take from
7777
fill_value : any, default np.nan
7878
Fill value to replace -1 values with
79-
allow_fill : boolean, default True
79+
allow_fill : bool, default True
8080
If False, indexer is assumed to contain no -1 values so no filling
8181
will be done. This short-circuits computation of a mask. Result is
8282
undefined if allow_fill == False and -1 is present in indexer.

pandas/core/dtypes/cast.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def maybe_upcast_putmask(result: np.ndarray, mask: np.ndarray) -> np.ndarray:
508508
result : ndarray
509509
The destination array. This will be mutated in-place if no upcasting is
510510
necessary.
511-
mask : boolean ndarray
511+
mask : np.ndarray[bool]
512512
513513
Returns
514514
-------

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
If 0 or 'index': apply function to each column.
232232
If 1 or 'columns': apply function to each row.""",
233233
"inplace": """
234-
inplace : boolean, default False
234+
inplace : bool, default False
235235
If True, performs operation inplace and returns None.""",
236236
"optional_by": """
237237
by : str or list of str
@@ -251,7 +251,7 @@
251251
you to specify a location to update with some value.""",
252252
}
253253

254-
_numeric_only_doc = """numeric_only : boolean, default None
254+
_numeric_only_doc = """numeric_only : bool or None, default None
255255
Include only float, int, boolean data. If None, will attempt to use
256256
everything, then use only numeric data
257257
"""

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@
181181
"axes_single_arg": "int or labels for object",
182182
"args_transpose": "axes to permute (int or label for object)",
183183
"inplace": """
184-
inplace : boolean, default False
184+
inplace : bool, default False
185185
If True, performs operation inplace and returns None.""",
186186
"optional_by": """
187187
by : str or list of str

pandas/core/groupby/categorical.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ def recode_for_groupby(
3434
Parameters
3535
----------
3636
c : Categorical
37-
sort : boolean
37+
sort : bool
3838
The value of the sort parameter groupby was called with.
39-
observed : boolean
39+
observed : bool
4040
Account only for the observed values
4141
4242
Returns
@@ -93,7 +93,7 @@ def recode_from_groupby(
9393
Parameters
9494
----------
9595
c : Categorical
96-
sort : boolean
96+
sort : bool
9797
The value of the sort parameter groupby was called with.
9898
ci : CategoricalIndex
9999
The codes / categories to recode

pandas/core/groupby/grouper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def _get_grouper(self, obj, validate: bool = True):
293293
Parameters
294294
----------
295295
obj : the subject object
296-
validate : boolean, default True
296+
validate : bool, default True
297297
if True, validate the grouper
298298
299299
Returns

pandas/core/groupby/ops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,8 @@ class BinGrouper(BaseGrouper):
817817
----------
818818
bins : the split index of binlabels to group the item of axis
819819
binlabels : the label list
820-
filter_empty : boolean, default False
821-
mutated : boolean, default False
820+
filter_empty : bool, default False
821+
mutated : bool, default False
822822
indexer : a intp array
823823
824824
Examples

pandas/core/indexing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ def _align_series(self, indexer, ser: Series, multiindex_indexer: bool = False):
20092009
Indexer used to get the locations that will be set to `ser`.
20102010
ser : pd.Series
20112011
Values to assign to the locations specified by `indexer`.
2012-
multiindex_indexer : boolean, optional
2012+
multiindex_indexer : bool, optional
20132013
Defaults to False. Should be set to True if `indexer` was from
20142014
a `pd.MultiIndex`, to avoid unnecessary broadcasting.
20152015

pandas/core/missing.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def _interp_limit(invalid, fw_limit, bw_limit):
789789
790790
Parameters
791791
----------
792-
invalid : boolean ndarray
792+
invalid : np.ndarray[bool]
793793
fw_limit : int or None
794794
forward limit to index
795795
bw_limit : int or None

pandas/core/resample.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ def _upsample(self, method, limit=None, fill_value=None):
12721272
"""
12731273
Parameters
12741274
----------
1275-
method : string {'backfill', 'bfill', 'pad', 'ffill'}
1275+
method : {'backfill', 'bfill', 'pad', 'ffill'}
12761276
Method for upsampling.
12771277
limit : int, default None
12781278
Maximum size gap to fill when reindexing.

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"axes_single_arg": "{0 or 'index'}",
163163
"axis": """axis : {0 or 'index'}
164164
Parameter needed for compatibility with DataFrame.""",
165-
"inplace": """inplace : boolean, default False
165+
"inplace": """inplace : bool, default False
166166
If True, performs operation inplace and returns None.""",
167167
"unique": "np.ndarray",
168168
"duplicated": "Series",

pandas/core/sorting.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def lexsort_indexer(
278278
----------
279279
keys : sequence of arrays
280280
Sequence of ndarrays to be sorted by the indexer
281-
orders : boolean or list of booleans, optional
281+
orders : bool or list of booleans, optional
282282
Determines the sorting order for each element in keys. If a list,
283283
it must be the same length as keys. This determines whether the
284284
corresponding element in keys should be sorted in ascending

pandas/core/tools/datetimes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def _maybe_cache(
171171
arg : listlike, tuple, 1-d array, Series
172172
format : string
173173
Strftime format to parse time
174-
cache : boolean
174+
cache : bool
175175
True attempts to create a cache of converted values
176176
convert_listlike : function
177177
Conversion function to apply on dates
@@ -313,9 +313,9 @@ def _convert_listlike_datetimes(
313313
error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore'
314314
infer_datetime_format : bool, default False
315315
inferring format behavior from to_datetime
316-
dayfirst : boolean
316+
dayfirst : bool
317317
dayfirst parsing behavior from to_datetime
318-
yearfirst : boolean
318+
yearfirst : bool
319319
yearfirst parsing behavior from to_datetime
320320
exact : bool, default True
321321
exact format matching behavior from to_datetime

pandas/io/clipboards.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def to_clipboard(obj, excel=True, sep=None, **kwargs): # pragma: no cover
8686
Parameters
8787
----------
8888
obj : the object to write to the clipboard
89-
excel : boolean, defaults to True
89+
excel : bool, defaults to True
9090
if True, use the provided separator, writing in a csv
9191
format for allowing easy pasting into excel.
9292
if False, write a string representation of the object

pandas/io/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,9 @@ def get_handle(
565565
Passing compression options as keys in dict is now
566566
supported for compression modes 'gzip' and 'bz2' as well as 'zip'.
567567
568-
memory_map : boolean, default False
568+
memory_map : bool, default False
569569
See parsers._parser_params for more information.
570-
is_text : boolean, default True
570+
is_text : bool, default True
571571
Whether the type of the content passed to the file/buffer is string or
572572
bytes. This is not the same as `"b" not in mode`. If a string content is
573573
passed to a binary file/buffer, a wrapper is inserted.

pandas/io/excel/_odfreader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class ODFReader(BaseExcelReader):
2323
2424
Parameters
2525
----------
26-
filepath_or_buffer : string, path to be parsed or
26+
filepath_or_buffer : str, path to be parsed or
2727
an open readable stream.
2828
storage_options : dict, optional
2929
passed to fsspec for appropriate URLs (see ``_get_filepath_or_buffer``)

pandas/io/excel/_openpyxl.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ def __init__(
488488
489489
Parameters
490490
----------
491-
filepath_or_buffer : string, path object or Workbook
491+
filepath_or_buffer : str, path object or Workbook
492492
Object to be parsed.
493493
storage_options : dict, optional
494494
passed to fsspec for appropriate URLs (see ``_get_filepath_or_buffer``)

pandas/io/excel/_xlrd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self, filepath_or_buffer, storage_options: StorageOptions = None):
1515
1616
Parameters
1717
----------
18-
filepath_or_buffer : string, path object or Workbook
18+
filepath_or_buffer : str, path object or Workbook
1919
Object to be parsed.
2020
storage_options : dict, optional
2121
passed to fsspec for appropriate URLs (see ``_get_filepath_or_buffer``)

0 commit comments

Comments
 (0)