Skip to main content
`Ctrl`+`K`

# pandas.errors.PerformanceWarning

exception pandas.errors.PerformanceWarning

  Warning raised when there is a possible performance impact.

  This warning is typically raised when an operation may be slower than expected due to the data structure or access pattern being used.

  See also

  `DataFrame.set_index`

    Set the DataFrame index using existing columns.

  `DataFrame.loc`

    Access a group of rows and columns by label(s) or a boolean array.

  Examples

      >>> 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