Skip to content

Commit

Permalink
fix multi-index edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy authored and TomNicholas committed Feb 5, 2024
1 parent 07b9856 commit be99673
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xarray/core/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,9 @@ def create_coords_with_default_indexes(
variable = as_variable(obj, name=name, auto_convert=False)

if variable.dims == (name,):
# still needed to convert to IndexVariable first due to some
# pandas multi-index edge cases.
variable = variable.to_index_variable()
idx, idx_vars = create_default_index_implicit(variable, all_variables)
indexes.update({k: idx for k in idx_vars})
variables.update(idx_vars)
Expand Down

0 comments on commit be99673

Please sign in to comment.