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

Add a "drop" option to squeeze #242

Closed
shoyer opened this issue Oct 1, 2014 · 3 comments · Fixed by #1153
Closed

Add a "drop" option to squeeze #242

shoyer opened this issue Oct 1, 2014 · 3 comments · Fixed by #1153

Comments

@shoyer
Copy link
Member

shoyer commented Oct 1, 2014

If True, squeezed dimensions should be dropped from the resulting object (instead of being retained as scalar)

@naught101
Copy link

Not sure if it's worth a separate feature request, but it'd be great to have a drop option in .isel() as well. For example:

>>> ds
<xarray.Dataset>
Dimensions:  (lat: 360, lon: 720, time: 2928)
Coordinates:
  * lon      (lon) float64 0.25 0.75 1.25 1.75 2.25 2.75 3.25 3.75 4.25 4.75 ...
  * lat      (lat) float64 -89.75 -89.25 -88.75 -88.25 -87.75 -87.25 -86.75 ...
  * time     (time) datetime64[ns] 2012-01-01 2012-01-01T03:00:00 ...
Data variables:
    dswrf    (time, lat, lon) float64 446.5 444.9 445.3 447.8 452.4 456.3 ...

>>> ds.isel(lat=0, lon=0, drop=True)
<xarray.Dataset>
Dimensions:  (time: 2928)
Coordinates:
  * time     (time) datetime64[ns] 2012-01-01 2012-01-01T03:00:00 ...
Data variables:
    dswrf    (time) float64 446.5 444.9 445.3 447.8 452.4 456.3 ...

This would be useful for making .to_dataframe() more efficient, too, I suspect, since I have to currently do forcing.isel(lat=0, lon=0).to_dataframe()[['dswrf']] to remove the (constant) lat/lon data from the dataframe.

@shoyer
Copy link
Member Author

shoyer commented May 3, 2016

@naught101 Yes, I think that would be useful.

@naught101
Copy link

Awesome, thanks shoyer! :)

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

Successfully merging a pull request may close this issue.

2 participants