xarray.core.accessor_str.StringAccessor.startswith#
- StringAccessor.startswith(pat)[source]#
Test if the start of each string in the array matches a pattern.
The pattern pat can either be a
str
or array-like ofstr
. If array-like, it will be broadcast and applied elementwise.- Parameters:
pat (
str
) – Character sequence. Regular expressions are not accepted. If array-like, it is broadcast.- Returns:
startswith (array of
bool
) – An array of booleans indicating whether the given pattern matches the start of each string element.
Examples
>>> da = xr.DataArray(["$100", "£23", "100"], dims="x") >>> da <xarray.DataArray (x: 3)> Size: 48B array(['$100', '£23', '100'], dtype='<U4') Dimensions without coordinates: x >>> startswith = da.str.startswith("$") >>> startswith <xarray.DataArray (x: 3)> Size: 3B array([ True, False, False]) Dimensions without coordinates: x