Skip to content
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

Dataset.mean drops coordinates #1470

Closed
ignamv opened this issue Jul 5, 2017 · 1 comment · Fixed by #2156
Closed

Dataset.mean drops coordinates #1470

ignamv opened this issue Jul 5, 2017 · 1 comment · Fixed by #2156
Labels

Comments

@ignamv
Copy link
Contributor

ignamv commented Jul 5, 2017

Hi,

Dataset.mean drops coordinates, unlike DataArray.mean:

x = xarray.DataArray([2., 4.], 
                     coords={'a':[1., 2.], 'b': 3.}, 
                     dims=['a'],
                     name='name')
print 'DataArray mean:'
print x.mean(dim='a')
print 'Dataset mean:'
print x.to_dataset().mean(dim='a')['name']

Output

DataArray mean
<xarray.DataArray 'name' ()>
array(3.0)
Coordinates:
    b        float64 3.0
Dataset mean
<xarray.DataArray 'name' ()>
array(3.0)

Thanks
Ignacio

@shoyer shoyer added the bug label Jul 5, 2017
@shoyer
Copy link
Member

shoyer commented Jul 5, 2017

Thanks for the report.

I'm marking this as a bug: I think we should probably keep the extra coordinates in both cases, but it should certainly be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants