MCPcopy
hub / github.com/pydata/xarray / Coordinates

Class Coordinates

xarray/core/coordinates.py:202–873  ·  view source on GitHub ↗

Dictionary like container for Xarray coordinates (variables + indexes). This collection is a mapping of coordinate names to :py:class:`~xarray.DataArray` objects. It can be passed directly to the :py:class:`~xarray.Dataset` and :py:class:`~xarray.DataArray` constructors via their `

Source from the content-addressed store, hash-verified

200
201
202class Coordinates(AbstractCoordinates):
203 """Dictionary like container for Xarray coordinates (variables + indexes).
204
205 This collection is a mapping of coordinate names to
206 :py:class:`~xarray.DataArray` objects.
207
208 It can be passed directly to the :py:class:`~xarray.Dataset` and
209 :py:class:`~xarray.DataArray` constructors via their `coords` argument. This
210 will add both the coordinates variables and their index.
211
212 Coordinates are either:
213
214 - returned via the :py:attr:`Dataset.coords`, :py:attr:`DataArray.coords`,
215 and :py:attr:`DataTree.coords` properties,
216 - built from Xarray or Pandas index objects
217 (e.g., :py:meth:`Coordinates.from_xindex` or
218 :py:meth:`Coordinates.from_pandas_multiindex`),
219 - built manually from input coordinate data and Xarray ``Index`` objects via
220 :py:meth:`Coordinates.__init__` (beware that no consistency check is done
221 on those inputs).
222
223 To create new coordinates from an existing Xarray ``Index`` object, use
224 :py:meth:`Coordinates.from_xindex` instead of
225 :py:meth:`Coordinates.__init__`. The latter is useful, e.g., for creating
226 coordinates with no default index.
227
228 Parameters
229 ----------
230 coords: dict-like, optional
231 Mapping where keys are coordinate names and values are objects that
232 can be converted into a :py:class:`~xarray.Variable` object
233 (see :py:func:`~xarray.as_variable`). If another
234 :py:class:`~xarray.Coordinates` object is passed, its indexes
235 will be added to the new created object.
236 indexes: dict-like, optional
237 Mapping where keys are coordinate names and values are
238 :py:class:`~xarray.indexes.Index` objects. If None (default),
239 pandas indexes will be created for each dimension coordinate.
240 Passing an empty dictionary will skip this default behavior.
241
242 Examples
243 --------
244 Create a dimension coordinate with a default (pandas) index:
245
246 >>> xr.Coordinates({"x": [1, 2]})
247 Coordinates:
248 * x (x) int64 16B 1 2
249
250 Create a dimension coordinate with no index:
251
252 >>> xr.Coordinates(coords={"x": [1, 2]}, indexes={})
253 Coordinates:
254 x (x) int64 16B 1 2
255
256 Create a new Coordinates object from existing dataset coordinates
257 (indexes are passed):
258
259 >>> ds = xr.Dataset(coords={"x": [1, 2]})

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…