Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
DataFrame.unstack(label) accepts wrong labels if index is flat #18303
Code Sample, a copy-pastable example if possible
In : df = pd.DataFrame(index=range(2), columns=pd.MultiIndex.from_product([range(2), range(2)])) In : df.unstack('mistake') Out: 0 0 0 NaN 1 NaN 1 0 NaN 1 NaN 1 0 0 NaN 1 NaN 1 0 NaN 1 NaN dtype: object
An error should be raised.
Yes, I'm suggesting it should raise a
By the way, I've always found the error message
@toobaz : Ah, okay, so not quite answering my question, BUT that's fine since your answer is pretty good justification for the issue anyhow.
As for your other point, yes, that's also fair. If you want, you can open another issue for that OR just open a PR to patch the behavior if it's clear how to fix.