-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Added docs example for xarray.Dataset.get()
#2894
Conversation
doc/data-structures.rst
Outdated
ds['temperature_double'] = (('x', 'y', 'time'), temp * 2) | ||
ds['precipitation_double'] = (('x', 'y', 'time'), precip * 2) | ||
|
||
list(ds.get(['temperature', 'temperature_double'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why list
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above. I wasnt sure what to make of this either but kept if for consistency.
doc/data-structures.rst
Outdated
@@ -401,6 +401,20 @@ operations keep around coordinates: | |||
list(ds[['x']]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why there is a list
here either :) but @jbusecke I think you just need to add ds[['x', 'temperature']]
as an example here since the text already talks about passing a list of variable names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see. Honestly I find the ds[['x']]
line quite confusing without context. Why should I chose one of the dimensions?
Should I remove the list(...)
calls alltoghether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the list
calls need to be removed.
And I think changing ds[['x']]
to ds[['x', 'temperature']]
is probably all that is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh the .get
example is great too, let's keep that.
For context: we didn't explicitly implement a I'm not sure it's particularly useful to show examples using |
Oh I see. It returns None if any of the keys is not found. That might indeed lead to confusion. |
I think this is probably a better idea. To be honest, I don't know if |
I am still a bit puzzled over the |
Yes, I think it would make more sense to add an example with another variable. |
How about this one? |
I missed that Thanks @jbusecke |
* master: (29 commits) Handle the character array dim name (pydata#2896) Partial fix for pydata#2841 to improve formatting. (pydata#2906) docs: Move quick overview one level up (pydata#2890) Manually specify chunks in open_zarr (pydata#2530) Minor improvement of docstring for Dataset (pydata#2904) Fix minor typos in docstrings (pydata#2903) Added docs example for `xarray.Dataset.get()` (pydata#2894) Bugfix for docs build instructions (pydata#2897) Return correct count for scalar datetime64 arrays (pydata#2892) Indexing with an empty array (pydata#2883) BUG: Fix pydata#2864 by adding the missing vrt parameters (pydata#2865) Reduce length of cftime resample tests (pydata#2879) WIP: type annotations (pydata#2877) decreased pytest verbosity (pydata#2881) Fix mypy typing error in cftime_offsets.py (pydata#2878) update links to https (pydata#2872) revert to 0.12.2 dev 0.12.1 release Various fixes for explicit Dataset.indexes (pydata#2858) Fix minor typo in docstring (pydata#2860) ...
Added example of
xarray.Dataset.get
method and alternativeds[var_list]
syntax.