Converting to object before then unstack works, whereas automatic upcast does not happen. Missing values are replaced with NaT instead of automatically upcasting to object and filling with the requested value.
In [44]: td = [Timedelta(days=i) for i in range(4)]
In [45]: data = Series(td)
In [46]: data.index = MultiIndex.from_tuples(
....: [('x', 'a'), ('x', 'b'), ('y', 'b'), ('z', 'a')])
In [47]: data.unstack(fill_value='foo')
Out[47]:
a b
x 0 days 1 days
y NaT 2 days
z 3 days NaT
In [48]: data.astype(np.object_).unstack(fill_value='foo')
Out[48]:
a b
x 0 days 00:00:00 1 days 00:00:00
y foo 2 days 00:00:00
z 3 days 00:00:00 foo
Culprit is some outdated code in _maybe_promote.
Comment From: amcpherson
Follows from work done for #9746.
Comment From: jreback
thanks @amcpherson for the clear issue!
Comment From: jbrockmendel
It isn't clear to me that this should be supported.
Comment From: mroeschke
Yeah I would expect this to raise