pydata / pydata/xarray

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

Open
#10,118 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug topic-documentation
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What happened?

The data structures documentation in user guide states that:

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.
https://github.com/pydata/xarray/blob/48be37601d3fe7495a0a5ddff20a854582298da5/doc/user-guide/data-structures.rst?plain=1#L68-L70

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open doc/user-guide/data-structures.rst around lines 57-70 and compare the coords description with the following DataArray example. Update the description so it covers a list of coordinate lists and its ordering with dims; done means the text no longer contradicts the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
pandas, python
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.