Closed
Description
A bit of an edge case
In [1]: import pandas as pd
In [2]: arr = pd.date_range('2017', periods=4, tz='US/Eastern')
In [3]: s = pd.Series(arr, index=[(0, 1), (0, 2), (0, 3), (0, 4)])
In [4]: s[(0, 1)] = float('NaN')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/sandbox/pandas-ip/pandas/pandas/core/series.py in setitem(key, value)
871 try:
--> 872 self._set_with_engine(key, value)
873 return
~/sandbox/pandas-ip/pandas/pandas/core/series.py in _set_with_engine(self, key, value)
930 try:
--> 931 self.index._engine.set_value(values, key, value)
932 return
TypeError: Argument 'arr' has incorrect type (expected numpy.ndarray, got DatetimeIndex)
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
<ipython-input-4-0a0fdcf8dcd6> in <module>()
----> 1 s[(0, 1)] = float('NaN')
~/sandbox/pandas-ip/pandas/pandas/core/series.py in __setitem__(self, key, value)
922 # do the setitem
923 cacher_needs_updating = self._check_is_chained_assignment_possible()
--> 924 setitem(key, value)
925 if cacher_needs_updating:
926 self._maybe_update_cacher()
~/sandbox/pandas-ip/pandas/pandas/core/series.py in setitem(key, value)
904 if (isinstance(key, tuple) and
905 not isinstance(self.index, MultiIndex)):
--> 906 raise ValueError("Can only tuple-index with a MultiIndex")
907
908 # python 3 type errors should be raised
ValueError: Can only tuple-index with a MultiIndex
xref #19907 (comment)