Skip to content

Description of coords type in documentation contradicts the example following it. #10118

Open
@dorchard

Description

@dorchard

What happened?

The data structures documentation in user guide states that:

  • coords: a list or dictionary of coordinates. If a list, it should be a
    list of tuples where the first element is the dimension name and the second
    - ``coords``: a list or dictionary of coordinates. If a list, it should be a
    list of tuples where the first element is the dimension name and the second
    element is the corresponding coordinate array_like object.

But the example immediately following it has a list of coords that is not a list of tuples:

locs = ["IA", "IL", "IN"]
times = pd.date_range("2000-01-01", periods=4)
foo = xr.DataArray(data, coords=[times, locs], dims=["time", "space"])

instead [times, locs] is a just a list of lists.

locs = ["IA", "IL", "IN"]
times = pd.date_range("2000-01-01", periods=4)
foo = xr.DataArray(data, coords=[times, locs], dims=["time", "space"])

I believe the code is correct though so just the description of coords needs an update and should be clear that if you have just a list of coordinate lists, then the order of the outer list should match the order of the dims list.

What did you expect to happen?

Example not to contradict the description of the type.

Minimal Complete Verifiable Example

N/A

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

N/A

Anything else we need to know?

No response

Environment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions