sklearn.utils._safe_indexing
-
sklearn.utils._safe_indexing(X, indices, *, axis=0)[source] -
Return rows, items or columns of X using indices.
Warning
This utility is documented, but private. This means that backward compatibility might be broken without any deprecation cycle.
- Parameters
-
-
Xarray-like, sparse-matrix, list, pandas.DataFrame, pandas.Series -
Data from which to sample rows, items or columns.
listare only supported whenaxis=0. -
indicesbool, int, str, slice, array-like -
- If
axis=0, boolean and integer array-like, integer slice, and scalar integer are supported. -
-
If axis=1: -
- to select a single column,
indicescan be ofinttype for allXtypes andstronly for dataframe. The selected subset will be 1D, unlessXis a sparse matrix in which case it will be 2D. - to select multiples columns,
indicescan be one of the following:list,array,slice. The type used in these containers can be one of the following:int, ‘bool’ andstr. However,stris only supported whenXis a dataframe. The selected subset will be 2D.
- to select a single column,
-
- If
-
axisint, default=0 -
The axis along which
Xwill be subsampled.axis=0will select rows whileaxis=1will select columns.
-
- Returns
-
- subset
-
Subset of X on axis 0 or 1.
Notes
CSR, CSC, and LIL sparse matrices are supported. COO sparse matrices are not supported.
© 2007–2020 The scikit-learn developers
Licensed under the 3-clause BSD License.
https://scikit-learn.org/0.24/modules/generated/sklearn.utils._safe_indexing.html