pandas.errors.IndexingError#
- exception pandas.errors.IndexingError[source]#
Exception is raised when trying to index and there is a mismatch in dimensions.
Raised by properties like
pandas.DataFrame.iloc
when an indexer is out of bounds orpandas.DataFrame.loc
when its index is unalignable to the frame index.See also
DataFrame.iloc
Purely integer-location based indexing for selection by position.
DataFrame.loc
Access a group of rows and columns by label(s) or a boolean array.
Examples
>>> df = pd.DataFrame({"A": [1, 1, 1]}) >>> df.loc[..., ..., "A"] ... # IndexingError: indexer may only contain one '...' entry >>> df = pd.DataFrame({"A": [1, 1, 1]}) >>> df.loc[1, ..., ...] ... # IndexingError: Too many indexers >>> df[pd.Series([True], dtype=bool)] ... # IndexingError: Unalignable boolean Series provided as indexer... >>> s = pd.Series(range(2), index=pd.MultiIndex.from_product([["a", "b"], ["c"]])) >>> s.loc["a", "c", "d"] ... # IndexingError: Too many indexers