Set levels on a MultiIndex
The pandas.MultiIndex.set_levels() method is used to set new levels on a MultiIndex.
Syntax:
MultiIndex.set_levels(levels, level=None, inplace=None, verify_integrity=True)
To work with MultiIndex in Python Pandas, we need to import the pandas library. Below is the syntax,
import pandas as pd
Python code to set levels on a MultiIndex
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer