replace a dim with a coordinate from another dataset
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
I often want a function that takes a dataarray / dataset and replaces a dimension with a coordinate from a different dataset.
@shoyer proposed the following simple solution.
def replace_dim(da, olddim, newdim):
renamed = da.rename({olddim: newdim.name})
# note that alignment along a dimension is skipped when you are overriding
# the relevant coordinate values
renamed.coords[newdim.name] = newdim
return renamed
Is this of broad enough interest to add a build in method for?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the DataArray and Dataset APIs alongside the proposed replace_dim function, focusing on how a dimension and coordinate from another dataset should be represented. Decide whether this belongs as a built-in method and define the expected behavior; done means the supported operation is documented and its behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100