Pandas 警告:PerformanceWarning: indexing past lexsort depth may impact performance.

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, '否', '否', '否'), :])

参考该帖子


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部