pandas.Flags

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

Flags that apply to pandas objects.

New in version 1.2.0.

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

Warning

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.

Notes

Attributes can be set in two ways

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

Attributes

allows_duplicate_labels

Whether this object allows duplicate labels.