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

Method _to_dataset_whole

xarray/core/dataarray.py:629–654  ·  view source on GitHub ↗
(
        self, name: Hashable = None, shallow_copy: bool = True
    )

Source from the content-addressed store, hash-verified

627 return dataset
628
629 def _to_dataset_whole(
630 self, name: Hashable = None, shallow_copy: bool = True
631 ) -> Dataset:
632 if name is None:
633 name = self.name
634 if name is None:
635 raise ValueError(
636 "unable to convert unnamed DataArray to a "
637 "Dataset without providing an explicit name"
638 )
639 if name in self.coords:
640 raise ValueError(
641 "cannot create a Dataset from a DataArray with "
642 "the same name as one of its coordinates"
643 )
644 # use private APIs for speed: this is called by _to_temp_dataset(),
645 # which is used in the guts of a lot of operations (e.g., reindex)
646 variables = self._coords.copy()
647 variables[name] = self.variable
648 if shallow_copy:
649 for k in variables:
650 variables[k] = variables[k].copy(deep=False)
651 indexes = self._indexes
652
653 coord_names = set(self._coords)
654 return Dataset._construct_direct(variables, coord_names, indexes=indexes)
655
656 def to_dataset(
657 self,

Callers 6

_to_temp_datasetMethod · 0.95
to_datasetMethod · 0.95
to_dataframeMethod · 0.95
queryMethod · 0.95
to_dask_dataframeMethod · 0.95

Calls 2

copyMethod · 0.45
_construct_directMethod · 0.45

Tested by 1