xray.Dataset.assign_coords

Dataset.assign_coords(**kwargs)

Assign new coordinates to this object, returning a new object with all the original data in addition to the new coordinates.

Parameters:

kwargs : keyword, value pairs

keywords are the variables names. If the values are callable, they are computed on this object and assigned to new coordinate variables. If the values are not callable, (e.g. a DataArray, scalar, or array), they are simply assigned.

Returns:

assigned : same type as caller

A new object with the new coordinates in addition to the existing data.

See also

Dataset.assign

Notes

Since kwargs is a dictionary, the order of your arguments may not be preserved, and so the order of the new variables is not well defined. Assigning multiple variables within the same assign_coords is possible, but you cannot reference other variables created within the same assign_coords call.