html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue https://github.com/pydata/xarray/issues/7220#issuecomment-1291515219,https://api.github.com/repos/pydata/xarray/issues/7220,1291515219,IC_kwDOAMm_X85M-vVT,14371165,2022-10-26T05:18:52Z,2022-10-26T05:18:52Z,MEMBER,"Original looks like this: ```python # keep the attributes of x, the second parameter, by default to # be consistent with the `where` method of `DataArray` and `Dataset` keep_attrs = lambda attrs, context: attrs[1] ``` New one looks like this: ```python # keep the attributes of x, the second parameter, by default to # be consistent with the `where` method of `DataArray` and `Dataset` keep_attrs = lambda attrs, context: getattr(x, ""attrs"", {}) ``` I notice that the original return `attrs[1]` for some reason but the new doesn't. I haven't tried but try something like this: ```python def keep_attrs(attrs, context): attrs_ = getattrs(x, ""attrs"", {}) if attrs_: return attrs_[1] else: return attrs_ ``` I don't get where the x comes from though, seems scary to get something outside the function scope like this.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1423114234