col
one two
a t 0
u 1
v 2
w 3
对于以上结构的两层行索引 DataFrame,采用 data.loc[(c, u), col] 取数据时,一般情况下会触发如下警告:
PerformanceWarning: indexing past lexsort depth may impact performance.
这是因为索引没有排序,而是否排序对 DataFrame 的检索效率有较大影响,只要按如下:
data = data.sort_index()
给索引排个序就可消除该警告。