pandas.Flags#
- class pandas.Flags(obj, *, allows_duplicate_labels)[source]#
Flags that apply to pandas objects.
“Flags” differ from “metadata”. Flags reflect properties of the pandas object (the Series or DataFrame). Metadata refer to properties of the dataset, and should be stored in DataFrame.attrs.
- 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 anerrors.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 propagateallows_duplicate_labels
.
See also
DataFrame.attrs
Dictionary of global attributes of this dataset.
Series.attrs
Dictionary of global attributes of this dataset.
Examples
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.
Methods