pandas.errors.PerformanceWarning#

exception pandas.errors.PerformanceWarning[源代码]#

当可能对性能产生影响时发出的警告。

另请参阅

DataFrame.set_index

使用现有列设置 DataFrame 索引。

DataFrame.loc

通过标签或布尔数组访问一组行和列。

示例

>>> df = pd.DataFrame(
...     {"jim": [0, 0, 1, 1], "joe": ["x", "x", "z", "y"], "jolie": [1, 2, 3, 4]}
... )
>>> df = df.set_index(["jim", "joe"])
>>> df
          jolie
jim  joe
0    x    1
     x    2
1    z    3
     y    4
>>> df.loc[(1, "z")]
# PerformanceWarning: indexing past lexsort depth may impact performance.
df.loc[(1, 'z')]
          jolie
jim  joe
1    z        3