MCPcopy
hub / github.com/pydata/xarray / ensure_not_multiindex

Function ensure_not_multiindex

xarray/conventions.py:54–65  ·  view source on GitHub ↗
(var: Variable, name: T_Name = None)

Source from the content-addressed store, hash-verified

52
53
54def ensure_not_multiindex(var: Variable, name: T_Name = None) -> None:
55 # only the pandas multi-index dimension coordinate cannot be serialized (tuple values)
56 if isinstance(var._data, indexing.PandasMultiIndexingAdapter):
57 if name is None and isinstance(var, IndexVariable):
58 name = var.name
59 if var.dims == (name,):
60 raise NotImplementedError(
61 f"variable {name!r} is a MultiIndex, which cannot yet be "
62 "serialized. Instead, either use reset_index() "
63 "to convert MultiIndex levels into coordinate variables instead "
64 "or use https://cf-xarray.readthedocs.io/en/latest/coding.html."
65 )
66
67
68def encode_cf_variable(

Callers 1

encode_cf_variableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…