I need to turn a 3-dimensional xarray DataArray into a 1-dimension dataset/dataarray in order to create a cumulative distribution function. I attempted to use
Thank you for the help!
CodePudding user response:
You can stack the dimensions of an xarray.DataArray with xarray.DataArray.stack
. Passing an ellipsis (...
) in a list as the dimensions
argument will stack all dimensions to create a 1-D array:
stacked = da.stack(stacked=[...])
if at this point you'd like a numpy 1-D array containing all values, you can access the .values
attribute
stacked_values = stacked.values