draugr.pandas_utilities.multi_index_utilities.add_index_level

draugr.pandas_utilities.multi_index_utilities.add_index_level(old_index: Index, value: Any, name: Optional[str] = None, loc: int = 0) MultiIndex[source]

Expand a (multi)index by adding a level to it.

Parameters
  • old_index – The index to expand

  • name – The name of the new index level

  • value – Scalar or list-like, the values of the new index level

  • loc – Where to insert the level in the index, 0 is at the front, negative values count back from the rear end

Returns

A new multi-index with the new level added