xarray.core.accessor_str.StringAccessor.casefold

xarray.core.accessor_str.StringAccessor.casefold#

StringAccessor.casefold()[source]#

Convert strings in the array to be casefolded.

Casefolding is similar to converting to lowercase, but removes all case distinctions. This is important in some languages that have more complicated cases and case conversions. For example, the ‘ß’ character in German is case-folded to ‘ss’, whereas it is lowercased to ‘ß’.

Returns

casefolded (same type as values)

Examples

>>> da = xr.DataArray(["TEMPERATURE", "HuMiDiTy"], dims="x")
>>> da
<xarray.DataArray (x: 2)> Size: 88B
array(['TEMPERATURE', 'HuMiDiTy'], dtype='<U11')
Dimensions without coordinates: x
>>> casefolded = da.str.casefold()
>>> casefolded
<xarray.DataArray (x: 2)> Size: 88B
array(['temperature', 'humidity'], dtype='<U11')
Dimensions without coordinates: x
>>> da = xr.DataArray(["ß", "İ"], dims="x")
>>> da
<xarray.DataArray (x: 2)> Size: 8B
array(['ß', 'İ'], dtype='<U1')
Dimensions without coordinates: x
>>> casefolded = da.str.casefold()
>>> casefolded
<xarray.DataArray (x: 2)> Size: 16B
array(['ss', 'i̇'], dtype='<U2')
Dimensions without coordinates: x