pandas.errors.DuplicateLabelError#
- exception pandas.errors.DuplicateLabelError[source]#
- Error raised when an operation would introduce duplicate labels. - This error is typically encountered when performing operations on objects with allows_duplicate_labels=False and the operation would result in duplicate labels in the index. Duplicate labels can lead to ambiguities in indexing and reduce data integrity. - See also - Series.set_flags
- Return a new - Seriesobject with updated flags.
- DataFrame.set_flags
- Return a new - DataFrameobject with updated flags.
- Series.reindex
- Conform - Seriesobject to new index with optional filling logic.
- DataFrame.reindex
- Conform - DataFrameobject to new index with optional filling logic.
 - Examples - >>> s = pd.Series([0, 1, 2], index=["a", "b", "c"]).set_flags( ... allows_duplicate_labels=False ... ) >>> s.reindex(["a", "a", "b"]) Traceback (most recent call last): ... DuplicateLabelError: Index has duplicates. positions label a [0, 1]