Creation of an empty DataArray
See original GitHub issueI’d like to create an empty DataArray
, i.e., one with only NA values. The docstring of DataArray
says that data=None
is allowed, if a dataset argument is provided. However, the docstring doesn’t say anything about a dataset argument.
- I think there’s a bug in the docstring
- I’d like to pass data=None and get a
DataArray
with the coords/dims set up properly (as defined by thecoords
anddims
kwargs), but with avalues
array of NA.
Issue Analytics
- State:
- Created 9 years ago
- Reactions:10
- Comments:11 (7 by maintainers)
Top Results From Across the Web
python - Most straightforward/compact way to iteratively create ...
If you known coordinates beforehand, then you can initialize an empty DataArray, which is almost your last example. >>> da = xr.
Read more >xarray.DataArray
DataArray provides a wrapper around numpy ndarrays that uses labeled dimensions and coordinates to support metadata aware operations. The API is similar to...
Read more >How to create an xarray dataset from scratch - The Urbanist
This is just a code snippet to remind myself how to build an xarray dataset. Note: this post has been updated with further...
Read more >Basic data structures of xarray - Towards Data Science
The 2 basic data structures of xarray are introduced with examples on how to create DataArray and Dataset in xarray for beginners.
Read more >xarray.DataArray — xarray 0.7.1 documentation
DataArray provides a wrapper around numpy ndarrays that uses labeled dimensions and ... By default, an empty attribute dictionary is initialized.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It might also make sense then to implement all numpy-like constructors for
DataArray
, plus theempty()
, which is typically faster for larger arrays:.full()
(kind of what’s suggested here).ones()
.zeros()
.empty()
This should be trivial to implement.
Fixed the doc string for now, but this would still be a nice feature to add at some point.