skfolio.utils.tools.safe_indexing#
- skfolio.utils.tools.safe_indexing(X, indices, axis=0)[source]#
Return rows, items or columns of X using indices.
- Parameters:
- Xarray-like, sparse matrix, DataFrame or AssetPanel
Data from which to sample rows or columns. Lists and tuples support row indexing.
- indicesint, array-like, slice, or None
An integer, integer indices, a boolean mask, slice, or None. When
None, the entire data is returned. When aslice, standard Python slicing is used (zero-copy for NumPy arrays andAssetPanel).- axisint, default=0
The axis along which
Xwill be sub-sampled.axis=0will select rows whileaxis=1will select columns.
- Returns:
- subset
Subset of X along the selected axis.