I'm new to python so please call me on not including relevant information.
I've installed python, ipython, and am using the notebook on an Ubuntu installation in a VM.
I'm working through examples laid out in Wes McKinney's Python for Data Analysis. After the following import statements:
from pandas import Series, DataFrame
import pandas as pd
I defined a dataframe with:
series1 = Series(range(5), index=['a', 'a', 'b', 'b', 'c'])
And subsequently wanted to test the indexes uniqueness with:
series1.index.is_unique
And get this error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/home/username/<ipython-input-64-e42615bb2da2> in <module>()
----> 1 series1.index.is_unique
AttributeError: 'Index' object has no attribute 'is_unique'
The book indicates this attribute exists. Other stackoverflow questions and answers reference this attribute.
What am I doing wrong?
Thanks
After being asked what version of pandas I was using, I checked and it was 0.7.0 Upgrading with
pip install --upgrade pandas
Got me where I needed to be.
Make sure you are using an updated version, no issues here with 0.11.0
:
>>> from pandas import Series, DataFrame
>>> s = Series(range(5), index=['a', 'a', 'b', 'b', 'c'])
>>> s.index.is_unique
False
Either download the most recent version from here, or upgrade from command line:
pip install --upgrade pandas
For this snippet there's no need to import pandas as pd
on the second line, so I've removed it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With