Series doesn't have an is_unique attribute · Issue #11946 · pandas-dev/pandas (original) (raw)

Hello,

Series doesn't have is a is_unique attribute

Index have a is_unique attribute but not (values of a) Series

df.index.is_unique True

df['Column1'].is_unique


AttributeError Traceback (most recent call last) in () ----> 1 df['Date'].is_unique

//anaconda/envs/py27/lib/python2.7/site-packages/pandas/core/generic.pyc in getattr(self, name) 2358 return self[name] 2359 raise AttributeError("'%s' object has no attribute '%s'" % -> 2360 (type(self).name, name)) 2361 2362 def setattr(self, name, value):

AttributeError: 'Series' object has no attribute 'is_unique'

I'm doing this

def is_unique(ser): return len(np.unique(ser.values)) == len(ser.values)

but this kind of attribute could be useful when you want to set a column as index and ensure that there is no duplicate keys.

PS: I know there is

df.set_index('Column1', verify_integrity=True)