wide_to_long mishandles string arg for stubnames
· Issue #22468 · pandas-dev/pandas (original) (raw)
wide_to_long should sanitize/format input args BEFORE sanity checking.
This bug report pertains to wide_to_long() in master/pandas/core/reshape/melt.py
Code Sample, a copy-pastable example if possible
This check (line 411) needs to move below input sanitization (line 425).
if any(col in stubnames for col in df.columns): raise ValueError("stubname can't be identical to a column name")
Problem description
The intention of the sanity checking code is to check if any element of the list stubname is in the the list of column names and generate an exception (line 411). Unfortunately, this check occours before the input sanitization that ensures that stubnames is a list -- it is also permitted to be string. As it is, the sanity check sometimes looks for substrings in a string and sometimes looks for substrings in a list, depending on the arg type for stubnames.
Expected Output
na
Output of pd.show_versions()
It is in master branch on github as of 8/22/2018