解决多重索引用loc出现PerformanceWarning: indexing past lexsort depth may impact performance警告
问题描述:pandas用loc定位数据时,如果索引没有排序,会消耗更多的时间进行查找定位,所以报错 PerformanceWarning: indexing past lexsort depth may impact performance
解决方案:先排序在使用loc定位数据框
data = data.sort_index()