Pandas 警告:PerformanceWarning: indexing past lexsort depth may impact performance.
MultiIndex的深度太大,在使用loc查询时就会引起这样的警告。需要将索引排序,如果不排序会严重影响查询的性能。
df = pd.read_excel(io=excel_path, sheet_name='1S概览(合并后)', index_col=[0, 1, 2, 3, 4, 5, 6])
df = df.sort_index() # 将索引排序,如果不排序在loc查询时就会有上述警告
print(df.index.is_monotonic_increasing) # 查看是否排序
print(df.loc[('绝对值型', 3000, 'AC100V', 50, '否', '否', '否'), :])