@@ -476,7 +476,7 @@ def _calc_assign_results(
476
476
477
477
def assign_coords (
478
478
self ,
479
- coords : Mapping [ Any , Any ] | None = None ,
479
+ coords : Mapping | None = None ,
480
480
** coords_kwargs : Any ,
481
481
) -> Self :
482
482
"""Assign new coordinates to this object.
@@ -486,15 +486,21 @@ def assign_coords(
486
486
487
487
Parameters
488
488
----------
489
- coords : dict-like or None, optional
490
- A dict where the keys are the names of the coordinates
491
- with the new values to assign. If the values are callable, they are
492
- computed on this object and assigned to new coordinate variables.
493
- If the values are not callable, (e.g. a ``DataArray``, scalar, or
494
- array), they are simply assigned. A new coordinate can also be
495
- defined and attached to an existing dimension using a tuple with
496
- the first element the dimension name and the second element the
497
- values for this new coordinate.
489
+ coords : mapping of dim to coord, optional
490
+ A mapping whose keys are the names of the coordinates and values are the
491
+ coordinates to assign. The mapping will generally be a dict or
492
+ :class:`Coordinates`.
493
+
494
+ * If a value is a standard data value — for example, a ``DataArray``,
495
+ scalar, or array — the data is simply assigned as a coordinate.
496
+
497
+ * If a value is callable, it is called with this object as the only
498
+ parameter, and the return value is used as new coordinate variables.
499
+
500
+ * A coordinate can also be defined and attached to an existing dimension
501
+ using a tuple with the first element the dimension name and the second
502
+ element the values for this new coordinate.
503
+
498
504
**coords_kwargs : optional
499
505
The keyword arguments form of ``coords``.
500
506
One of ``coords`` or ``coords_kwargs`` must be provided.
@@ -595,14 +601,6 @@ def assign_coords(
595
601
Attributes:
596
602
description: Weather-related data
597
603
598
- Notes
599
- -----
600
- Since ``coords_kwargs`` is a dictionary, the order of your arguments
601
- may not be preserved, and so the order of the new variables is not well
602
- defined. Assigning multiple variables within the same ``assign_coords``
603
- is possible, but you cannot reference other variables created within
604
- the same ``assign_coords`` call.
605
-
606
604
See Also
607
605
--------
608
606
Dataset.assign
0 commit comments