Merge two sets of coordinates to create a new Dataset The method implements the logic used for joining coordinates in the result of a binary operation performed on xarray objects: - If two index coordinates conflict (are not equal), an exception is raised. You mus
(
self,
other: Mapping[Any, Any] | None,
*,
compat: CompatOptions | CombineKwargDefault = "minimal",
)
| 540 | self._update_coords(variables, indexes) |
| 541 | |
| 542 | def merge( |
| 543 | self, |
| 544 | other: Mapping[Any, Any] | None, |
| 545 | *, |
| 546 | compat: CompatOptions | CombineKwargDefault = "minimal", |
| 547 | ) -> Dataset: |
| 548 | """Merge two sets of coordinates to create a new Dataset |
| 549 | |
| 550 | The method implements the logic used for joining coordinates in the |
| 551 | result of a binary operation performed on xarray objects: |
| 552 | |
| 553 | - If two index coordinates conflict (are not equal), an exception is |
| 554 | raised. You must align your data before passing it to this method. |
| 555 | - If an index coordinate and a non-index coordinate conflict, the non- |
| 556 | index coordinate is dropped. |
| 557 | - If two non-index coordinates conflict, both are dropped. |
| 558 | |
| 559 | Parameters |
| 560 | ---------- |
| 561 | other : dict-like, optional |
| 562 | A :py:class:`Coordinates` object or any mapping that can be turned |
| 563 | into coordinates. |
| 564 | compat : {"identical", "equals", "broadcast_equals", "no_conflicts", "override", "minimal"}, default: "minimal" |
| 565 | Compatibility checks to use between coordinate variables. |
| 566 | |
| 567 | Returns |
| 568 | ------- |
| 569 | merged : Dataset |
| 570 | A new Dataset with merged coordinates. |
| 571 | """ |
| 572 | from xarray.core.dataset import Dataset |
| 573 | |
| 574 | if other is None: |
| 575 | return self.to_dataset() |
| 576 | |
| 577 | if not isinstance(other, Coordinates): |
| 578 | other = Dataset(coords=other).coords |
| 579 | |
| 580 | coords, indexes = merge_coordinates_without_align([self, other], compat=compat) |
| 581 | coord_names = set(coords) |
| 582 | return Dataset._construct_direct( |
| 583 | variables=coords, coord_names=coord_names, indexes=indexes |
| 584 | ) |
| 585 | |
| 586 | def __or__(self, other: Mapping[Any, Any] | None) -> Coordinates: |
| 587 | """Merge two sets of coordinates to create a new Coordinates object |
no test coverage detected