Skip to content

DOC: update array-like parameters if scalars accepted #41985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pandas/core/algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def factorize_array(
mask: np.ndarray | None = None,
) -> tuple[npt.NDArray[np.intp], np.ndarray]:
"""
Factorize an array-like to codes and uniques.
Factorize a numpy array to codes and uniques.

This doesn't do any coercion of types or unboxing before factorization.

Expand Down Expand Up @@ -910,7 +910,7 @@ def duplicated(

Parameters
----------
values : ndarray-like
values : nd.array, ExtensionArray or Series
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't now match the type annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #42604

Array over which to check for duplicate values.
keep : {'first', 'last', False}, default 'first'
- ``first`` : Mark duplicates as ``True`` except for the first
Expand Down Expand Up @@ -1412,8 +1412,8 @@ def take(

Parameters
----------
arr : sequence
Non array-likes (sequences without a dtype) are coerced
arr : array-like or scalar value
Non array-likes (sequences/scalars without a dtype) are coerced
to an ndarray.
indices : sequence of integers
Indices to be taken.
Expand Down Expand Up @@ -1523,11 +1523,11 @@ def searchsorted(arr, value, side="left", sorter=None) -> np.ndarray:

Parameters
----------
arr: array-like
arr: np.ndarray, ExtensionArray, Series
Input array. If `sorter` is None, then it must be sorted in
ascending order, otherwise `sorter` must be an array of indices
that sort it.
value : array-like
value : array-like or scalar
Values to insert into `arr`.
side : {'left', 'right'}, optional
If 'left', the index of the first suitable location found is given.
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,8 @@ def searchsorted(self, value, side="left", sorter=None):

Parameters
----------
value : array-like
Values to insert into `self`.
value : array-like, list or scalar
Value(s) to insert into `self`.
side : {'left', 'right'}, optional
If 'left', the index of the first suitable location found is given.
If 'right', return the last such index. If there is no suitable
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class SparseArray(OpsMixin, PandasObject, ExtensionArray):

Parameters
----------
data : array-like
data : array-like or scalar
A dense array of values to store in the SparseArray. This may contain
`fill_value`.
sparse_index : SparseIndex, optional
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ def factorize(self, sort: bool = False, na_sentinel: int | None = -1):

Parameters
----------
value : array-like
value : array-like or scalar
Values to insert into `self`.
side : {{'left', 'right'}}, optional
If 'left', the index of the first suitable location found is given.
Expand Down
52 changes: 26 additions & 26 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def is_object_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -316,7 +316,7 @@ def is_datetime64_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -349,7 +349,7 @@ def is_datetime64tz_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -390,7 +390,7 @@ def is_timedelta64_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -424,7 +424,7 @@ def is_period_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -460,7 +460,7 @@ def is_interval_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -498,7 +498,7 @@ def is_categorical_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype to check.

Returns
Expand Down Expand Up @@ -534,7 +534,7 @@ def is_string_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -635,7 +635,7 @@ def is_any_int_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -680,7 +680,7 @@ def is_integer_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -732,7 +732,7 @@ def is_signed_integer_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -784,7 +784,7 @@ def is_unsigned_integer_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -828,7 +828,7 @@ def is_int64_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -878,7 +878,7 @@ def is_datetime64_any_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -920,7 +920,7 @@ def is_datetime64_ns_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -970,7 +970,7 @@ def is_timedelta64_ns_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -999,7 +999,7 @@ def is_datetime_or_timedelta_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -1039,7 +1039,7 @@ def is_numeric_v_string_like(a: ArrayLike, b):

Parameters
----------
a : array-like
a : array-like, scalar
The first object to check.
b : array-like, scalar
The second object to check.
Expand Down Expand Up @@ -1146,7 +1146,7 @@ def needs_i8_conversion(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -1190,7 +1190,7 @@ def is_numeric_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -1234,7 +1234,7 @@ def is_float_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -1266,7 +1266,7 @@ def is_bool_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -1337,7 +1337,7 @@ def is_extension_type(arr) -> bool:

Parameters
----------
arr : array-like
arr : array-like, scalar
The array-like to check.

Returns
Expand Down Expand Up @@ -1489,7 +1489,7 @@ def is_complex_dtype(arr_or_dtype) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array or dtype to check.

Returns
Expand Down Expand Up @@ -1546,7 +1546,7 @@ def get_dtype(arr_or_dtype) -> DtypeObj:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype object whose dtype we want to extract.

Returns
Expand Down Expand Up @@ -1580,7 +1580,7 @@ def _is_dtype_type(arr_or_dtype, condition) -> bool:

Parameters
----------
arr_or_dtype : array-like
arr_or_dtype : array-like or dtype
The array-like or dtype object whose dtype we want to extract.
condition : callable[Union[np.dtype, ExtensionDtypeType]]

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6129,7 +6129,7 @@ def drop(self, labels, errors: str_t = "raise") -> Index:

Parameters
----------
labels : array-like
labels : array-like or scalar
errors : {'ignore', 'raise'}, default 'raise'
If 'ignore', suppress error and existing labels are dropped.

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ def setitem(self, indexer, value):

Parameters
----------
indexer : tuple, list-like, array-like, slice
indexer : tuple, list-like, array-like, slice, int
The subset of self.values to set
value : object
The value being set
Expand Down Expand Up @@ -1461,7 +1461,7 @@ def setitem(self, indexer, value):

Parameters
----------
indexer : tuple, list-like, array-like, slice
indexer : tuple, list-like, array-like, slice, int
The subset of self.values to set
value : object
The value being set
Expand Down