I'm confused about the difference between Pandas Series objects when using reindex_like and related features. For example, consider the following Series objects:
>>> import numpy
>>> import pandas
>>> series = pandas.Series([1, 2, 3])
>>> x = pandas.Series([True]).reindex_like(series).fillna(True)
>>> y = pandas.Series(True, index=series.index)
>>> x
0 True
1 True
2 True
>>> y
0 True
1 True
2 True
On the surface x and y appear to be identical in their contents and indexing. However, they must be different in some way because one of them causes an error when using numpy.logical_and() and the other does not.
>>> numpy.logical_and(series, y)
0 True
1 True
2 True
>>> numpy.logical_and(series, x)
Traceback (most recent call last):
File "<ipython-input-10-e2050a2015bf>", line 1, in <module>
numpy.logical_and(series, x)
AttributeError: logical_and
What is numpy.logical() and complaining about here? I don't see the difference between the two series, x and y. However, there must be some subtle difference.
The Pandas documentation says the Series object is a valid argument to "most NumPy functions." Clearly this is true somewhat in this case. Apparently the creation mechanism makes x unusable to this particular numpy function.
As a side-note, which of the two creation mechanisms, reindex_like() and the index argument are more efficient and idiomatic for this scenario? Maybe there is another/better way I haven't considered also.
numpy.logical_and(series, x)works without error for me inpandas-0.9.0-py2.7...