You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obviously this would't make sense for lists or arrays being passed in, but in the case of a Series, it would be nice to have the name persisted.
From glancing at the source, it looks like this would be somewhat simple to implement, the naive approach might be something like:
from pandas.core.arrays.categorical import _factorize_from_iterables
from pandas.core.reshape.util import cartesian_product
if not is_list_like(iterables):
raise TypeError("Input must be a list / sequence of iterables.")
elif is_iterator(iterables):
iterables = list(iterables)
if names is None:
names = [el.name if hasattr(el, 'name') else None for el in iterables]
codes, levels = _factorize_from_iterables(iterables)
codes = cartesian_product(codes)
return MultiIndex(levels, codes, sortorder=sortorder, names=names)
The text was updated successfully, but these errors were encountered:
@WillAyd I think this change would also make the behavior of from_frame a bit more consistent. from_framedoes infer names from its inputs. I will put together a PR
Uh oh!
There was an error while loading. Please reload this page.
It would be convenient to have
from_product
infer level names from inputs if at all possible.Current behavior
Current workaround
Obviously this would't make sense for lists or arrays being passed in, but in the case of a
Series
, it would be nice to have the name persisted.From glancing at the source, it looks like this would be somewhat simple to implement, the naive approach might be something like:
The text was updated successfully, but these errors were encountered: