class pandas.Flags(obj, *, allows_duplicate_labels)[source]#

Flags that apply to pandas objects.

New in version 1.2.0.

objSeries or DataFrame

The object these flags are associated with.

allows_duplicate_labelsbool, default True

Whether to allow duplicate labels in this object. By default, duplicate labels are permitted. Setting this to False will cause an errors.DuplicateLabelError to be raised when index (or columns for DataFrame) is not unique, or any subsequent operation on introduces duplicates. See Disallowing Duplicate Labels for more.


This is an experimental feature. Currently, many methods fail to propagate the allows_duplicate_labels value. In future versions it is expected that every method taking or returning one or more DataFrame or Series objects will propagate allows_duplicate_labels.


Attributes can be set in two ways

>>> df = pd.DataFrame()
>>> df.flags
>>> df.flags.allows_duplicate_labels = False
>>> df.flags
>>> df.flags['allows_duplicate_labels'] = True
>>> df.flags



Whether this object allows duplicate labels.