BUG: pandas.tools.util.cartesian_product doesn't work on DatetimeIndex objects · Issue #6439 · pandas-dev/pandas (original) (raw)
This breaks the new pandas.MultiIndex.from_product
function when one of the product arrays is DatetimeIndex. Observe:
>>> import pandas as pd
>>> from pandas.tools.util import cartesian_product
>>> x, y = cartesian_product([[1, 2], pd.date_range('2000-01-01', periods=2)])
>>> print x
[1 1 2 2]
>>> print y.values
['1999-12-31T16:00:00.000000000-0800' '1999-12-31T16:00:00.000000000-0800'
'2000-01-01T16:00:00.000000000-0800' '2000-01-01T16:00:00.000000000-0800']
If cartesian_product
was working properly, the dates should actually be [1999, 2000, 1999, 2000].
The simple fix would be to convert everything into a numpy array before calculating the cartesian product.