Skip to content

Commit 6388370

Browse files
authored
CLN: spelling fixes in docstrings (#34039)
* spelling fixes * add whatsnew entry * fix doctests * and one more that wasn't caught
1 parent 3ed7dff commit 6388370

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+81
-82
lines changed

pandas/core/aggregation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def normalize_keyword_aggregation(kwargs: dict) -> Tuple[dict, List[str], List[i
8989
]
9090
uniquified_aggspec = _make_unique_kwarg_list(aggspec_order)
9191

92-
# get the new indice of columns by comparison
92+
# get the new index of columns by comparison
9393
col_idx_order = Index(uniquified_aggspec).get_indexer(uniquified_order)
9494
return aggspec, columns, col_idx_order
9595

@@ -182,7 +182,7 @@ def maybe_mangle_lambdas(agg_spec: Any) -> Any:
182182
is_dict = is_dict_like(agg_spec)
183183
if not (is_dict or is_list_like(agg_spec)):
184184
return agg_spec
185-
mangled_aggspec = type(agg_spec)() # dict or OrderdDict
185+
mangled_aggspec = type(agg_spec)() # dict or OrderedDict
186186

187187
if is_dict:
188188
for key, aggfuncs in agg_spec.items():

pandas/core/algorithms.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def _ensure_data(
125125

126126
except (TypeError, ValueError, OverflowError):
127127
# if we are trying to coerce to a dtype
128-
# and it is incompat this will fall through to here
128+
# and it is incompatible this will fall through to here
129129
return ensure_object(values), np.dtype("object")
130130

131131
# datetimelike
@@ -473,7 +473,7 @@ def _factorize_array(
473473
values : ndarray
474474
na_sentinel : int, default -1
475475
size_hint : int, optional
476-
Passsed through to the hashtable's 'get_labels' method
476+
Passed through to the hashtable's 'get_labels' method
477477
na_value : object, optional
478478
A value in `values` to consider missing. Note: only use this
479479
parameter when you know that you don't have any values pandas would
@@ -1239,7 +1239,7 @@ def get_indexer(current_indexer, other_indexer):
12391239
break
12401240

12411241
# Now find all values which are equal to
1242-
# the (nsmallest: largest)/(nlarrgest: smallest)
1242+
# the (nsmallest: largest)/(nlargest: smallest)
12431243
# from our series.
12441244
border_value = values == values[values.index[-1]]
12451245

pandas/core/arrays/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def _values_for_factorize(self) -> Tuple[np.ndarray, Any]:
696696
na_value : object
697697
The value in `values` to consider missing. This will be treated
698698
as NA in the factorization routines, so it will be coded as
699-
`na_sentinal` and not included in `uniques`. By default,
699+
`na_sentinel` and not included in `uniques`. By default,
700700
``np.nan`` is used.
701701
702702
Notes

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,7 @@ def __setitem__(self, key, value):
20152015
# tuple of indexers (dataframe)
20162016
elif isinstance(key, tuple):
20172017
# only allow 1 dimensional slicing, but can
2018-
# in a 2-d case be passd (slice(None),....)
2018+
# in a 2-d case be passed (slice(None),....)
20192019
if len(key) == 2:
20202020
if not com.is_null_slice(key[0]):
20212021
raise AssertionError("invalid slicing for a 1-ndim categorical")

pandas/core/arrays/datetimelike.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _check_compatible_with(
198198
----------
199199
other
200200
setitem : bool, default False
201-
For __setitem__ we may have stricter compatibility resrictions than
201+
For __setitem__ we may have stricter compatibility restrictions than
202202
for comparisons.
203203
204204
Raises

pandas/core/arrays/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def __array__(self, dtype=None) -> np.ndarray:
284284
elif dtype == bool:
285285
return ~self._isnan
286286

287-
# This will raise TypeErorr for non-object dtypes
287+
# This will raise TypeError for non-object dtypes
288288
return np.array(list(self), dtype=object)
289289

290290
def __arrow_array__(self, type=None):

pandas/core/arrays/sparse/array.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ def __getitem__(self, key):
784784
# TODO: I think we can avoid densifying when masking a
785785
# boolean SparseArray with another. Need to look at the
786786
# key's fill_value for True / False, and then do an intersection
787-
# on the indicies of the sp_values.
787+
# on the indices of the sp_values.
788788
if isinstance(key, SparseArray):
789789
if is_bool_dtype(key):
790790
key = key.to_dense()

pandas/core/arrays/timedeltas.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def _generate_range(cls, start, end, periods, freq, closed=None):
258258
if start is None and end is None:
259259
if closed is not None:
260260
raise ValueError(
261-
"Closed has to be None if not both of startand end are defined"
261+
"Closed has to be None if not both of start and end are defined"
262262
)
263263

264264
left_closed, right_closed = dtl.validate_endpoints(closed)
@@ -877,7 +877,7 @@ def sequence_to_td64ns(data, copy=False, unit="ns", errors="raise"):
877877
"""
878878
Parameters
879879
----------
880-
array : list-like
880+
data : list-like
881881
copy : bool, default False
882882
unit : str, default "ns"
883883
The timedelta unit to treat integers as multiples of.
@@ -930,7 +930,7 @@ def sequence_to_td64ns(data, copy=False, unit="ns", errors="raise"):
930930
copy = copy and not copy_made
931931

932932
elif is_float_dtype(data.dtype):
933-
# cast the unit, multiply base/frace separately
933+
# cast the unit, multiply base/frac separately
934934
# to avoid precision issues from float -> int
935935
mask = np.isnan(data)
936936
m, p = precision_from_unit(unit)

pandas/core/config_init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ def use_inf_as_na_cb(key):
604604
: str
605605
The plotting backend to use. The default value is "matplotlib", the
606606
backend provided with pandas. Other backends can be specified by
607-
prodiving the name of the module that implements the backend.
607+
providing the name of the module that implements the backend.
608608
"""
609609

610610

pandas/core/construction.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ def _try_cast(
543543
return subarr
544544

545545
try:
546-
# GH#15832: Check if we are requesting a numeric dype and
546+
# GH#15832: Check if we are requesting a numeric dtype and
547547
# that we can convert the data to the requested dtype.
548548
if is_integer_dtype(dtype):
549549
# this will raise if we have e.g. floats

pandas/core/dtypes/cast.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ def maybe_downcast_numeric(result, dtype, do_round: bool = False):
198198
return result
199199

200200
if isinstance(result, list):
201-
# reached via groupoby.agg _ohlc; really this should be handled
202-
# earlier
201+
# reached via groupby.agg._ohlc; really this should be handled earlier
203202
result = np.array(result)
204203

205204
def trans(x):
@@ -1693,7 +1692,7 @@ def convert_scalar_for_putitemlike(scalar, dtype: np.dtype):
16931692
Parameters
16941693
----------
16951694
scalar : scalar
1696-
dtype : np.dtpye
1695+
dtype : np.dtype
16971696
16981697
Returns
16991698
-------

pandas/core/dtypes/concat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def _concatenate_2d(to_concat, axis: int):
357357
def concat_datetime(to_concat, axis=0, typs=None):
358358
"""
359359
provide concatenation of an datetimelike array of arrays each of which is a
360-
single M8[ns], datetimet64[ns, tz] or m8[ns] dtype
360+
single M8[ns], datetime64[ns, tz] or m8[ns] dtype
361361
362362
Parameters
363363
----------

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ def _repr_fits_horizontal_(self, ignore_width: bool = False) -> bool:
644644
645645
In case of non-interactive session, no boundaries apply.
646646
647-
`ignore_width` is here so ipnb+HTML output can behave the way
647+
`ignore_width` is here so ipynb+HTML output can behave the way
648648
users expect. display.max_columns remains in effect.
649649
GH3541, GH3573
650650
"""

pandas/core/groupby/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,7 @@ def filter(self, func, dropna=True, *args, **kwargs):
15551555
15561556
Parameters
15571557
----------
1558-
f : function
1558+
func : function
15591559
Function to apply to each subframe. Should return True or False.
15601560
dropna : Drop groups that do not pass the filter. True by default;
15611561
If False, groups that evaluate False are filled with NaNs.

pandas/core/groupby/ops.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ def _get_cython_func_and_vals(
405405
406406
Parameters
407407
----------
408-
kind : sttr
409-
how : srt
408+
kind : str
409+
how : str
410410
values : np.ndarray
411411
is_numeric : bool
412412
@@ -643,7 +643,7 @@ def agg_series(
643643
return self._aggregate_series_pure_python(obj, func)
644644

645645
elif obj.index._has_complex_internals:
646-
# Pre-empt TypeError in _aggregate_series_fast
646+
# Preempt TypeError in _aggregate_series_fast
647647
return self._aggregate_series_pure_python(obj, func)
648648

649649
try:
@@ -895,7 +895,7 @@ def agg_series(
895895
assert len(self.bins) > 0 # otherwise we'd get IndexError in get_result
896896

897897
if is_extension_array_dtype(obj.dtype):
898-
# pre-empt SeriesBinGrouper from raising TypeError
898+
# preempt SeriesBinGrouper from raising TypeError
899899
return self._aggregate_series_pure_python(obj, func)
900900

901901
dummy = obj[:0]

pandas/core/indexers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ def check_array_indexer(array: AnyArrayLike, indexer: Any) -> Any:
441441
"""
442442
from pandas.core.construction import array as pd_array
443443

444-
# whathever is not an array-like is returned as-is (possible valid array
444+
# whatever is not an array-like is returned as-is (possible valid array
445445
# indexers that are not array-like: integer, slice, Ellipsis, None)
446446
# In this context, tuples are not considered as array-like, as they have
447447
# a specific meaning in indexing (multi-dimensional indexing)

pandas/core/indexes/multi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ def get_loc_level(self, key, level=0, drop_level: bool = True):
27842784
def maybe_mi_droplevels(indexer, levels, drop_level: bool):
27852785
if not drop_level:
27862786
return self[indexer]
2787-
# kludgearound
2787+
# kludge around
27882788
orig_index = new_index = self[indexer]
27892789
levels = [self._get_level_number(i) for i in levels]
27902790
for i in sorted(levels, reverse=True):

pandas/core/indexes/period.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ def get_loc(self, key, method=None, tolerance=None):
473473
Parameters
474474
----------
475475
key : Period, NaT, str, or datetime
476-
String or datetime key must be parseable as Period.
476+
String or datetime key must be parsable as Period.
477477
478478
Returns
479479
-------

pandas/core/indexes/range.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def _make_evaluate_binop(op, step=False):
741741
"""
742742
Parameters
743743
----------
744-
op : callable that accepts 2 parms
744+
op : callable that accepts 2 params
745745
perform the binary op
746746
step : callable, optional, default to False
747747
op to apply to the step parm if not None

pandas/core/indexing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class IndexingError(Exception):
9090

9191
class IndexingMixin:
9292
"""
93-
Mixin for adding .loc/.iloc/.at/.iat to Datafames and Series.
93+
Mixin for adding .loc/.iloc/.at/.iat to Dataframes and Series.
9494
"""
9595

9696
@property
@@ -1498,7 +1498,7 @@ def _convert_to_indexer(self, key, axis: int, is_setter: bool = False):
14981498
return key
14991499

15001500
def _get_setitem_indexer(self, key):
1501-
# GH#32257 Fall through to let numnpy do validation
1501+
# GH#32257 Fall through to let numpy do validation
15021502
return key
15031503

15041504
# -------------------------------------------------------------------
@@ -2257,9 +2257,9 @@ def need_slice(obj) -> bool:
22572257

22582258
def _non_reducing_slice(slice_):
22592259
"""
2260-
Ensurse that a slice doesn't reduce to a Series or Scalar.
2260+
Ensure that a slice doesn't reduce to a Series or Scalar.
22612261
2262-
Any user-paseed `subset` should have this called on it
2262+
Any user-passed `subset` should have this called on it
22632263
to make sure we're always working with DataFrames.
22642264
"""
22652265
# default to column slice, like DataFrame

pandas/core/internals/blocks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -825,7 +825,7 @@ def setitem(self, indexer, value):
825825

826826
return self.astype(dtype).setitem(indexer, value)
827827

828-
# value must be storeable at this moment
828+
# value must be storable at this moment
829829
if is_extension_array_dtype(getattr(value, "dtype", None)):
830830
# We need to be careful not to allow through strings that
831831
# can be parsed to EADtypes

pandas/core/internals/managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ def replace_list(
600600
""" do a list replace """
601601
inplace = validate_bool_kwarg(inplace, "inplace")
602602

603-
# figure out our mask a-priori to avoid repeated replacements
603+
# figure out our mask apriori to avoid repeated replacements
604604
values = self.as_array()
605605

606606
def comp(s, regex=False):

pandas/core/nanops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _bn_ok_dtype(dtype: DtypeObj, name: str) -> bool:
143143

144144
# GH 9422
145145
# further we also want to preserve NaN when all elements
146-
# are NaN, unlinke bottleneck/numpy which consider this
146+
# are NaN, unlike bottleneck/numpy which consider this
147147
# to be 0
148148
if name in ["nansum", "nanprod"]:
149149
return False

pandas/core/ops/array_ops.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def na_arithmetic_op(left, right, op, str_rep: Optional[str], is_cmp: bool = Fal
131131
"""
132132
Return the result of evaluating op on the passed in values.
133133
134-
If native types are not compatible, try coersion to object dtype.
134+
If native types are not compatible, try coercion to object dtype.
135135
136136
Parameters
137137
----------
@@ -184,7 +184,7 @@ def arithmetic_op(left: ArrayLike, right: Any, op, str_rep: str):
184184
185185
Returns
186186
-------
187-
ndarrray or ExtensionArray
187+
ndarray or ExtensionArray
188188
Or a 2-tuple of these in the case of divmod or rdivmod.
189189
"""
190190

@@ -315,7 +315,7 @@ def logical_op(left: ArrayLike, right: Any, op) -> ArrayLike:
315315
316316
Returns
317317
-------
318-
ndarrray or ExtensionArray
318+
ndarray or ExtensionArray
319319
"""
320320
fill_int = lambda x: x
321321

pandas/core/reshape/merge.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ def __init__(
652652
) = self._get_merge_keys()
653653

654654
# validate the merge keys dtypes. We may need to coerce
655-
# to avoid incompat dtypes
655+
# to avoid incompatible dtypes
656656
self._maybe_coerce_merge_keys()
657657

658658
# If argument passed to validate,
@@ -1067,7 +1067,7 @@ def _get_merge_keys(self):
10671067
return left_keys, right_keys, join_names
10681068

10691069
def _maybe_coerce_merge_keys(self):
1070-
# we have valid mergees but we may have to further
1070+
# we have valid merges but we may have to further
10711071
# coerce these if they are originally incompatible types
10721072
#
10731073
# for example if these are categorical, but are not dtype_equal
@@ -1392,7 +1392,7 @@ def _restore_dropped_levels_multijoin(
13921392
13931393
"""
13941394

1395-
def _convert_to_mulitindex(index) -> MultiIndex:
1395+
def _convert_to_multiindex(index) -> MultiIndex:
13961396
if isinstance(index, MultiIndex):
13971397
return index
13981398
else:
@@ -1402,7 +1402,7 @@ def _convert_to_mulitindex(index) -> MultiIndex:
14021402
# the returned index if of type Index
14031403
# Assure that join_index is of type MultiIndex
14041404
# so that dropped levels can be appended
1405-
join_index = _convert_to_mulitindex(join_index)
1405+
join_index = _convert_to_multiindex(join_index)
14061406

14071407
join_levels = join_index.levels
14081408
join_codes = join_index.codes

pandas/core/reshape/pivot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def _add_margins(
210210
grand_margin = _compute_grand_margin(data, values, aggfunc, margins_name)
211211

212212
if table.ndim == 2:
213-
# i.e. DataFramae
213+
# i.e. DataFrame
214214
for level in table.columns.names[1:]:
215215
if margins_name in table.columns.get_level_values(level):
216216
raise ValueError(msg)

pandas/core/reshape/tile.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def _bins_to_cuts(
440440
categories=labels if len(set(labels)) == len(labels) else None,
441441
ordered=ordered,
442442
)
443-
# TODO: handle mismach between categorical label order and pandas.cut order.
443+
# TODO: handle mismatch between categorical label order and pandas.cut order.
444444
np.putmask(ids, na_mask, 0)
445445
result = algos.take_nd(labels, ids - 1)
446446

0 commit comments

Comments
 (0)