ENH: improve extract and get_dummies methods for Index.str (fix for #9980) by mortada · Pull Request #9985 · pandas-dev/pandas (original) (raw)
I think its worthile to change _wrap_result to something like this:
def _wrap_result(self, result, **kwargs):
if not isinstance(result, (Series, Index)):
result = type(self.series)(result, **kwargs)
.....
should work if expand=False