Closed
Description
In [5]: idx = pd.period_range('2017', periods=12, freq="A-DEC")
In [6]: idx <= idx[[0]]
Out[6]:
array([ True, False, False, False, False, False, False, False, False,
False, False, False])
This should raise.
Both DatetimeIndex
and TimedeltaIndex
do raise
In [8]: idx <= idx[[0]]
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-8a2a887e6efd> in <module>
----> 1 idx <= idx[[0]]
~/sandbox/pandas/pandas/core/indexes/datetimes.py in wrapper(self, other)
90
91 def wrapper(self, other):
---> 92 result = getattr(DatetimeArrayMixin, opname)(self, other)
93 if is_bool_dtype(result):
94 return result
~/sandbox/pandas/pandas/core/arrays/datetimes.py in wrapper(self, other)
133 else:
134 self._assert_tzawareness_compat(other)
--> 135 result = meth(self, np.asarray(other))
136
137 result = com.values_from_object(result)
~/sandbox/pandas/pandas/core/arrays/datetimelike.py in cmp_method(self, other)
51 if isinstance(other, (np.ndarray, ABCIndexClass, ABCSeries)):
52 if other.ndim > 0 and len(self) != len(other):
---> 53 raise ValueError('Lengths must match to compare')
54
55 if needs_i8_conversion(self) and needs_i8_conversion(other):
ValueError: Lengths must match to compare