-
-
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
Make passing a DataArray for the xarray.concat dim argument equivalent to passing a pandas Index #1646
Comments
Agreed, this should definitely work! (I think the fact that it doesn't is probably related to the relatively recent change that made coordinate labels along dimensions optional.) |
This is the location of the helper function that parsing the Line 123 in 9763a66
|
I have a simple fix in #1812 . With that change, this works.
But if you provided a dimension name like
then |
Oh, this is trickier than I thought! The challenge is that once you make the DataArray, there is no good way to know if a default dimension name like The way to handle this currently is to pass a 1-dimensional
But this is a little verbose. Potentially we could call |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
One option here would be to take the name of the dataarray iff the dim name is In [7]: xr.concat([da,da], xr.DataArray(['x', 'y'], name='stat'))
Out[7]:
<xarray.DataArray 'air' (dim_0: 2, time: 2920, lat: 25, lon: 53)>
array([[[[241.2 , 242.5 , 243.5 , ..., 232.79999, 235.5 ,
238.59999],
[243.79999, 244.5 , 244.7 , ..., 232.79999, 235.29999,
295.19 ],
[297.69 , 298.09 , 298.09 , ..., 296.49 , 296.19 ,
295.69 ]]]], dtype=float32)
Coordinates:
* lat (lat) float32 75.0 72.5 70.0 67.5 65.0 ... 25.0 22.5 20.0 17.5 15.0
* lon (lon) float32 200.0 202.5 205.0 207.5 ... 322.5 325.0 327.5 330.0
* time (time) datetime64[ns] 2013-01-01 ... 2014-12-31T18:00:00
* dim_0 (dim_0) <U1 'x' 'y' # Very unlikely we even want `dim_0` here It's very unlikely we even want |
We could also make it only succeed if Supporting the tuple form also seems like a good idea |
Just pointing out that the documentation says "If dimension is provided as a DataArray or Index, its name is used as the dimension to concatenate along and the values are added as a coordinate." Which seems to currently be not true for a DataArray. |
Extending from #839, if I'm concatenating some DataArrays using concat,
I get an unnamed dimension without coordinates.
Using a pandas.Index,
I want the latter, not the former, but I expected the latter when using a DataArray.
The text was updated successfully, but these errors were encountered: