MCPcopy
hub / github.com/pydata/xarray / swapcase

Method swapcase

xarray/core/accessor_str.py:721–743  ·  view source on GitHub ↗

Convert strings in the array to be swapcased. Returns ------- swapcased : same type as values Examples -------- >>> import xarray as xr >>> da = xr.DataArray(["temperature", "PRESSURE", "HuMiDiTy"], dims="x") >>> da <

(self)

Source from the content-addressed store, hash-verified

719 return self._apply(func=lambda x: x.lower())
720
721 def swapcase(self) -> T_DataArray:
722 """
723 Convert strings in the array to be swapcased.
724
725 Returns
726 -------
727 swapcased : same type as values
728
729 Examples
730 --------
731 >>> import xarray as xr
732 >>> da = xr.DataArray(["temperature", "PRESSURE", "HuMiDiTy"], dims="x")
733 >>> da
734 <xarray.DataArray (x: 3)> Size: 132B
735 array(['temperature', 'PRESSURE', 'HuMiDiTy'], dtype='<U11')
736 Dimensions without coordinates: x
737 >>> swapcased = da.str.swapcase()
738 >>> swapcased
739 <xarray.DataArray (x: 3)> Size: 132B
740 array(['TEMPERATURE', 'pressure', 'hUmIdItY'], dtype='<U11')
741 Dimensions without coordinates: x
742 """
743 return self._apply(func=lambda x: x.swapcase())
744
745 def title(self) -> T_DataArray:
746 """

Callers 6

test_case_bytesFunction · 0.80
test_case_strFunction · 0.80
test_replace_callableFunction · 0.80
test_replace_literalFunction · 0.80
test_empty_str_methodsFunction · 0.80

Calls 1

_applyMethod · 0.95

Tested by 6

test_case_bytesFunction · 0.64
test_case_strFunction · 0.64
test_replace_callableFunction · 0.64
test_replace_literalFunction · 0.64
test_empty_str_methodsFunction · 0.64