pydata / pydata/xarray

Better "merge" defaults for Dataset.__setitem__ and Dataset.update

Open
#10,585 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What is your issue?

In dataset_update_method we call merge_core without specific values for join and compat. https://github.com/pydata/xarray/blob/e71c34174572b03e46e9d10bbea4528aef382021/xarray/structure/merge.py#L1063-L1068

These values default to join="outer" and compat="broadcast_equals"
https://github.com/pydata/xarray/blob/e71c34174572b03e46e9d10bbea4528aef382021/xarray/structure/merge.py#L639-L649.

We should probably migrate to join="left" and compat="override". Using override will avoid any potentially expensive equality comparisons for non-indexed coordiante variables. I am not sure how compat="override" interacts with priority_arg.

cc @shoyer

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

Start in xarray/structure/merge.py at dataset_update_method and the merge_core defaults around the referenced lines. Check how join="left" and compat="override" interact with priority_arg, then confirm that Dataset.setitem and Dataset.update use the intended defaults without the unnecessary equality comparisons.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.