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/7588#issuecomment-1460850301,https://api.github.com/repos/pydata/xarray/issues/7588,1460850301,IC_kwDOAMm_X85XEs59,127195910,2023-03-08T20:42:10Z,2023-03-14T19:43:51Z,NONE,"When using xr.merge with compat='minimal', the resulting Dataset may have unexpected behavior, including causing __len__ to return wrong and possibly negative values.
This is because compat='minimal' mode allows for the merging of datasets with non-matching dimensions and coordinates. When this happens, the merged dataset may contain ""empty"" dimensions or coordinates that have lost their original values and attributes.
To avoid this issue, you can either use compat='override' mode, which will overwrite conflicting dimensions and coordinates, or manually align and concatenate the datasets before merging them.
Here's an example of how to manually align and concatenate two datasets before merging them:
import xarray as xr
# create two sample datasets with different dimensions
ds1 = xr.Dataset({'foo': (['x', 'y'], [[1, 2], [3, 4]])}, coords={'x': [0, 1], 'y': [0, 1]})
ds2 = xr.Dataset({'bar': (['x', 'z'], [[5, 6], [7, 8]])}, coords={'x': [0, 1], 'z': [0, 1]})
# align and concatenate the datasets along the 'x' dimension
ds1_aligned = ds1.sel(x=slice(None, 1))
ds2_aligned = ds2.sel(x=slice(1, None))
merged = xr.merge([ds1_aligned, ds2_aligned])
In this example, we first slice each dataset to remove any non-matching dimensions and coordinates, and then concatenate them along the 'x' dimension. Finally, we merge the aligned datasets to create a single merged dataset without any corrupted dimensions or coordinates.
","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1611701140