pandas.Flags.allows_duplicate_labels#
- property Flags.allows_duplicate_labels#
此对象是否允许重复标签。
设置
allows_duplicate_labels=False
确保索引(和DataFrame的列)是唯一的。大多数接受和返回Series或DataFrame的方法都会传播allows_duplicate_labels
。看见 重复标签 想要更多。
参见
DataFrame.attrs
设置此对象的全局元数据。
DataFrame.set_flags
在此对象上设置全局标志。
示例
>>> df = pd.DataFrame({"A": [1, 2]}, index=['a', 'a']) >>> df.flags.allows_duplicate_labels True >>> df.flags.allows_duplicate_labels = False Traceback (most recent call last): ... pandas.errors.DuplicateLabelError: Index has duplicates. positions label a [0, 1]