Closed
Description
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)
<ipython-input-417-c450d4c4ceda> in <module>()
----> 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)