xr.open_mfdataset raised duplicate values #6297
-
I was trying to read multiple NetCDF files downloaded from here use A similar discussion can be found here. Like the situation in the discussion, the data I was trying to read has missing values, so why do the missing value issue raise duplicate values error? @TomNicholas mentioned dropping duplicates, but |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
You could either def drop_duplicates(obj, dim, keep="first"):
if dim not in obj.dims:
raise ValueError(f"'{dim}' not found in dimensions")
indexes = {dim: ~obj.get_index(dim).duplicated(keep=keep)}
return obj.isel(indexes) Given that this works on datasets as well as dataarrays I don't know why there isn't a |
Beta Was this translation helpful? Give feedback.
You could either
.map
thedrop_duplicates
method over the variables in the dataset, or just use the code in thedrop_duplicates
method directly on the dataset. Then you can create your own function to use withinpreprocess
like thisGiven that this works on datasets as well as dataarrays I don't know why there isn't a
Dataset.drop_duplicates
method - seems like we could add one.