-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add a combine_attrs parameter to Dataset.merge #4895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
2a237a0
add a combine_attrs kwarg to Dataset.merge
keewis 0323ec6
Merge branch 'master' into dataset-merge-combine_attrs
keewis 1d6a2e7
document the new drop_conflicts value
keewis 09c9343
test that combine_attrs is passed through
keewis 4263e11
fix the documented default of combine_attrs
keewis 61c63c0
update whats-new.rst
keewis ae17625
minor fix [skip-ci]
keewis 95ea7f0
Merge branch 'master' into dataset-merge-combine_attrs
keewis 3d93e68
minor fix [skip-ci]
keewis 689b690
remove a empty line [skip-ci]
keewis 17b083b
Merge branch 'master' into dataset-merge-combine_attrs
keewis 4c589cd
fix bad merge [skip-ci]
keewis 1a8e83f
Merge branch 'master' into dataset-merge-combine_attrs
keewis 7d6416a
fix bad merge [skip-ci]
keewis fd4c328
remove the blank line after rst lists [skip-ci]
keewis fb15914
Merge branch 'master' into dataset-merge-combine_attrs
keewis 3f51147
Merge branch 'master' into dataset-merge-combine_attrs
keewis 015f1ca
Merge branch 'master' into dataset-merge-combine_attrs
keewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3897,6 +3897,7 @@ def merge( | |||||
compat: str = "no_conflicts", | ||||||
join: str = "outer", | ||||||
fill_value: Any = dtypes.NA, | ||||||
combine_attrs: str = "override", | ||||||
) -> "Dataset": | ||||||
"""Merge the arrays of two datasets into a single dataset. | ||||||
|
||||||
|
@@ -3934,9 +3935,23 @@ def merge( | |||||
- 'left': use indexes from ``self`` | ||||||
- 'right': use indexes from ``other`` | ||||||
- 'exact': error instead of aligning non-equal indexes | ||||||
|
||||||
fill_value : scalar or dict-like, optional | ||||||
Value to use for newly missing values. If a dict-like, maps | ||||||
variable names (including coordinates) to fill values. | ||||||
combine_attrs : {"drop", "identical", "no_conflicts", "drop_conflicts", \ | ||||||
"override"}, default: "override" | ||||||
String indicating how to combine attrs of the objects being merged: | ||||||
dcherian marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
- "drop": empty attrs on returned Dataset. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that was copied from |
||||||
- "identical": all attrs must be the same on every object. | ||||||
- "no_conflicts": attrs from all objects are combined, any that have | ||||||
the same name must also have the same value. | ||||||
- "drop_conflicts": attrs from all objects are combined, any that have | ||||||
the same name but different values are dropped. | ||||||
- "override": skip comparing and copy attrs from the first dataset to | ||||||
the result. | ||||||
|
||||||
|
||||||
Returns | ||||||
------- | ||||||
|
@@ -3956,6 +3971,7 @@ def merge( | |||||
compat=compat, | ||||||
join=join, | ||||||
fill_value=fill_value, | ||||||
combine_attrs=combine_attrs, | ||||||
) | ||||||
return self._replace(**merge_result._asdict()) | ||||||
|
||||||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.