I ran into a problem when comparing two DatetimeIndex with different lengths in assert as follows:
In [1]: idx1 = pd.date_range('2010-01-01','2010-12-31',freq='D') In [2]: idx2 = pd.date_range('2010-01-01','2010-11-01',freq='D') In [3]: assert (idx1 == idx2).all()
I get an error message:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-17-ad2cfd6d11c2> in <module>() ----> 1 assert (idx1 == idx2).all() /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas-0.10.1.dev_dcd9df7-py2.7-macosx-10.8-x86_64.egg/pandas/tseries/index.pyc in wrapper(self, other) 75 result = func(other) 76 ---> 77 return result.view(np.ndarray) 78 79 return wrapper AttributeError: 'NotImplementedType' object has no attribute 'view'
Which is good if it is not implemented yet, but is there any way pandas do it?
Note: I have successfully used the following:
In [3]: assert list(idx1) == list(idx2)
So the following also works:
In [3]: assert list(df.index) == list(testindex)
But I would like to know if there is a more pandas th way to do this.
source share