Stream: python-questions
Topic: xarray.Dataset.groupby bug?
Stephen Yeager (May 12 2021 at 17:07):
Creating a monthly climatology of time-dependent variables in an xarray Dataset using groupby has the undesirable effect of introducing a monthly dimension in data variables that did not have time dimension to begin with. In the example below, I do not want 'depth_bnds' to acquire the 'month' dimension (squeeze=True does not help).
Screen-Shot-2021-05-12-at-11.00.59-AM.png
Deepak Cherian (May 12 2021 at 17:19):
This is slighlty hard to fix: https://github.com/pydata/xarray/issues/2145#issuecomment-391114129 . I recommend dropping it before the groupby and adding it back if you need it. Does it help if depth_bounds
is a coordinate variable instead?
Stephen Yeager (May 12 2021 at 18:45):
Yes. If I replace 'ds_en4' with 'ds_en4.set_coords('depth_bnds')', everything looks good.
Last updated: Jan 30 2022 at 12:01 UTC