str2d.Str2D.__getitem__
- Str2D.__getitem__(key: int | slice | Tuple[int | slice, ...] | List[int | slice]) Str2D [source]
Passing on the indexing to the structured array data. This is a wrapper around the structured array data’s __getitem__ method and returns a new Str2D object with the sliced data.
- Parameters:
key (Union[int, slice, Tuple[Union[int, slice], ...], List[Union[int, slice]]) – The index or slice to pass to the structured array data.
- Returns:
A new Str2D object with the sliced data.
- Return type:
Examples
Let’s create an instance of Str2D and assign it to the variable a.
from str2d import Str2D a = Str2D('''\ 012345 123450 234501 345012 ''') a
012345 123450 234501 345012
We can slice the data by passing a tuple of slices. The first slice is for the rows and the second slice is for the columns.
a[:-2, 1:]
12345 23450