MultiIndex.to_hierarchical()

pandas.MultiIndex.to_hierarchical

MultiIndex.to_hierarchical(n_repeat, n_shuffle=1)

Return a MultiIndex reshaped to conform to the shapes given by n_repeat and n_shuffle.

Useful to replicate and rearrange a MultiIndex for combination with another Index with n_repeat items.

登录查看完整内容
Parameters:

n_repeat : int

Number of times to repeat the labels on self

n_shuffle : int

Controls the reordering of the labels. If the result is going to be an inner level in a MultiIndex, n_shuffle will need to be greater than one. The size of each label must divisible by n_shuffle.