Return a copy of this Coordinates object.
(
self,
deep: bool = False,
memo: dict[int, Any] | None = None,
)
| 747 | return self._data._ipython_key_completions_() |
| 748 | |
| 749 | def copy( |
| 750 | self, |
| 751 | deep: bool = False, |
| 752 | memo: dict[int, Any] | None = None, |
| 753 | ) -> Self: |
| 754 | """Return a copy of this Coordinates object.""" |
| 755 | # do not copy indexes (may corrupt multi-coordinate indexes) |
| 756 | # TODO: disable variables deepcopy? it may also be problematic when they |
| 757 | # encapsulate index objects like pd.Index |
| 758 | variables = { |
| 759 | k: v._copy(deep=deep, memo=memo) for k, v in self.variables.items() |
| 760 | } |
| 761 | |
| 762 | # TODO: getting an error with `self._construct_direct`, possibly because of how |
| 763 | # a subclass implements `_construct_direct`. (This was originally the same |
| 764 | # runtime code, but we switched the type definitions in #8216, which |
| 765 | # necessitates the cast.) |
| 766 | return cast( |
| 767 | Self, |
| 768 | Coordinates._construct_direct( |
| 769 | coords=variables, indexes=dict(self.xindexes), dims=dict(self.sizes) |
| 770 | ), |
| 771 | ) |
| 772 | |
| 773 | def drop_vars( |
| 774 | self, |