A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/11946 below:

Series doesn't have an is_unique attribute · Issue #11946 · pandas-dev/pandas · GitHub

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)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4