Skip to content

Commit 40e8c15

Browse files
authored
forcibly rename the name of the pandas index (#161)
* forcibly rename the index * use the extracted name instead
1 parent dfd5ad2 commit 40e8c15

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xdggs/index.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,17 @@ def from_variables(
5858
*,
5959
options: Mapping[str, Any],
6060
) -> "DGGSIndex":
61-
_, var, _ = _extract_cell_id_variable(variables)
61+
name, var, _ = _extract_cell_id_variable(variables)
6262

6363
grid_name = var.attrs["grid_name"]
6464
cls = GRID_REGISTRY.get(grid_name)
6565
if cls is None:
6666
raise ValueError(f"unknown DGGS grid name: {grid_name}")
6767

68-
return cls.from_variables(variables, options=options)
68+
index = cls.from_variables(variables, options=options)
69+
index._pd_index.index.name = name
70+
71+
return index
6972

7073
def create_variables(
7174
self, variables: Mapping[Any, xr.Variable] | None = None

0 commit comments

Comments
 (0)