MCPcopy Index your code
hub / github.com/pydata/xarray / to_masked_array

Method to_masked_array

xarray/core/dataarray.py:4044–4060  ·  view source on GitHub ↗

Convert this array into a numpy.ma.MaskedArray Parameters ---------- copy : bool, default: True If True make a copy of the array in the result. If False, a MaskedArray view of DataArray.values is returned. Returns ------- resu

(self, copy: bool = True)

Source from the content-addressed store, hash-verified

4042 return pd.Series(self.values.reshape(-1), index=index, name=self.name)
4043
4044 def to_masked_array(self, copy: bool = True) -> np.ma.MaskedArray:
4045 """Convert this array into a numpy.ma.MaskedArray
4046
4047 Parameters
4048 ----------
4049 copy : bool, default: True
4050 If True make a copy of the array in the result. If False,
4051 a MaskedArray view of DataArray.values is returned.
4052
4053 Returns
4054 -------
4055 result : MaskedArray
4056 Masked where invalid values (nan or inf) occur.
4057 """
4058 values = self.to_numpy() # only compute lazy arrays once
4059 isnull = pd.isnull(values)
4060 return np.ma.MaskedArray(data=values, mask=isnull, copy=copy)
4061
4062 # path=None writes to bytes
4063 @overload

Callers 3

test_to_masked_arrayMethod · 0.95
newplotfuncFunction · 0.80

Calls 2

to_numpyMethod · 0.95
isnullMethod · 0.45

Tested by 2

test_to_masked_arrayMethod · 0.76