import random
random.shuffle(tuples)
s = pd.Series(np.random.randn(8), index=pd.MultiIndex.from_tuples(tuples))
s.sort_index()
s.sort_index(level=0)
s.sort_index(level=1)
s.index.set_names(["L1", "L2"], inplace=True)
s.sort_index(level="L1")
s.sort_index(level="L2")
df.T.sort_index(level=1, axis=1)
dfm = pd.DataFrame(
{"jim": [0, 0, 1, 1], "joe": ["x", "x", "z", "y"], "jolie": np.random.rand(4)}
)
dfm = dfm.set_index(["jim", "joe"])
dfm.loc[(1, 'z')] # この状態だとWarningする
dfm.loc[(0, 'y'):(1, 'z')]
dfm.index.is_monotonic_increasing
dfm = dfm.sort_index()
dfm.index.is_monotonic_increasing
dfm.loc[(0, "y"):(1, "z")] # この状態だとIndexingが正常に効く