From 1b1265085a1f378f8e3d3291f97c71b87b31a5a0 Mon Sep 17 00:00:00 2001 From: Irv Lustig Date: Sun, 13 Jun 2021 13:49:58 -0400 Subject: [PATCH] DOC: update array-like parameters if scalars accepted --- pandas/core/algorithms.py | 12 +++---- pandas/core/arrays/base.py | 4 +-- pandas/core/arrays/sparse/array.py | 2 +- pandas/core/base.py | 2 +- pandas/core/dtypes/common.py | 52 +++++++++++++++--------------- pandas/core/indexes/base.py | 2 +- pandas/core/internals/blocks.py | 4 +-- 7 files changed, 39 insertions(+), 39 deletions(-) diff --git a/pandas/core/algorithms.py b/pandas/core/algorithms.py index f26cf113f7d5e..196d9bc23c168 100644 --- a/pandas/core/algorithms.py +++ b/pandas/core/algorithms.py @@ -531,7 +531,7 @@ def factorize_array( mask: np.ndarray | None = None, ) -> tuple[np.ndarray, 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. @@ -910,7 +910,7 @@ def duplicated( Parameters ---------- - values : ndarray-like + values : nd.array, ExtensionArray or Series Array over which to check for duplicate values. keep : {'first', 'last', False}, default 'first' - ``first`` : Mark duplicates as ``True`` except for the first @@ -1415,8 +1415,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. @@ -1526,11 +1526,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. diff --git a/pandas/core/arrays/base.py b/pandas/core/arrays/base.py index 888c7cbbffb59..005bfc84a0301 100644 --- a/pandas/core/arrays/base.py +++ b/pandas/core/arrays/base.py @@ -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 diff --git a/pandas/core/arrays/sparse/array.py b/pandas/core/arrays/sparse/array.py index 7d3917203d7b6..9f3bb3277361b 100644 --- a/pandas/core/arrays/sparse/array.py +++ b/pandas/core/arrays/sparse/array.py @@ -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 diff --git a/pandas/core/base.py b/pandas/core/base.py index 104baa04d3459..5ba8024f986b4 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1133,7 +1133,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. diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py index 34b9a3f1f14ad..8e8fa69b28f31 100644 --- a/pandas/core/dtypes/common.py +++ b/pandas/core/dtypes/common.py @@ -163,7 +163,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 @@ -317,7 +317,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 @@ -350,7 +350,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 @@ -391,7 +391,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 @@ -425,7 +425,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 @@ -461,7 +461,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 @@ -499,7 +499,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 @@ -535,7 +535,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 @@ -636,7 +636,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 @@ -681,7 +681,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 @@ -733,7 +733,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 @@ -785,7 +785,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 @@ -829,7 +829,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 @@ -879,7 +879,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 @@ -921,7 +921,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 @@ -971,7 +971,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 @@ -1000,7 +1000,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 @@ -1040,7 +1040,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. @@ -1147,7 +1147,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 @@ -1191,7 +1191,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 @@ -1235,7 +1235,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 @@ -1267,7 +1267,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 @@ -1338,7 +1338,7 @@ def is_extension_type(arr) -> bool: Parameters ---------- - arr : array-like + arr : array-like, scalar The array-like to check. Returns @@ -1490,7 +1490,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 @@ -1547,7 +1547,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 @@ -1581,7 +1581,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]] diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index eaba30012a5b8..c479de7c2f8ce 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -5913,7 +5913,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. diff --git a/pandas/core/internals/blocks.py b/pandas/core/internals/blocks.py index 237d06402a0ee..f9291aa046aec 100644 --- a/pandas/core/internals/blocks.py +++ b/pandas/core/internals/blocks.py @@ -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 @@ -1457,7 +1457,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