Closed
Description
The documentation reads
Returns:
reduced : DataArray
New DataArray object with argmin applied to its data and the indicated dimension(s) removed.
However, what happens is that the numpy argmin output (single index into the flattened array at which the maximum/minimum is found) is wrapped in a dummy DataArray (similar behavior for Datasets also):
[In1]: x = np.linspace(0,1,5)
[In2]: y = np.linspace(0,1,6)
[In3]: z = np.random.randn(5,6)
[In4]: example = xr.DataArray(z, {'x':x,'y':y},('x','y'))
[In5]: print(example.argmin())
[Out5]: <xarray.DataArray ()>
array(10)
[In6]: example_ds = xr.Dataset(data_vars={'ex':example})
[In7]: print(example_ds.argmin())
[Out7]: <xarray.Dataset>
Dimensions: ()
Data variables:
ex int64 10
I realize that maybe for compatibility reasons it is necessary to make Datasets/DataArrays do this, but it seems like the documented behavior would be nicer. At any rate, the documentation should match the behavior.
Specs:
python 2.7
xarray 0.9.1
numpy 1.11.3