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

Method stack_dataarray

xarray/core/dataset.py:5422–5435  ·  view source on GitHub ↗
(da)

Source from the content-addressed store, hash-verified

5420 )
5421
5422 def stack_dataarray(da):
5423 # add missing dims/ coords and the name of the variable
5424
5425 missing_stack_coords = {variable_dim: da.name}
5426 for dim in set(stacking_dims) - set(da.dims):
5427 missing_stack_coords[dim] = None
5428
5429 missing_stack_dims = list(missing_stack_coords)
5430
5431 return (
5432 da.assign_coords(**missing_stack_coords)
5433 .expand_dims(missing_stack_dims)
5434 .stack({new_dim: (variable_dim,) + stacking_dims})
5435 )
5436
5437 # concatenate the arrays
5438 stackable_vars = [stack_dataarray(da) for da in self.data_vars.values()]

Callers

nothing calls this directly

Calls 3

stackMethod · 0.45
expand_dimsMethod · 0.45
assign_coordsMethod · 0.45

Tested by

no test coverage detected