blosc2.NDArray.slice#
- NDArray.slice(key: int | slice | Sequence[slice], **kwargs: Any) NDArray #
Get a (multidimensional) slice as a new NDArray.
- Parameters:
- Returns:
out – An array containing the requested data. The dtype will match that of self.
- Return type:
Examples
>>> import blosc2 >>> import numpy as np >>> shape = [23, 11] >>> a = np.arange(np.prod(shape)).reshape(shape) >>> # Create an array >>> b = blosc2.asarray(a) >>> slices = (slice(3, 7), slice(1, 11)) >>> # Get a slice as a new NDArray >>> c = b.slice(slices) >>> print(c.shape) (4, 10) >>> print(type(c)) <class 'blosc2.ndarray.NDArray'>