Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Melting with not present column does not produce error #23575
Melting with not present column does not produce error #23575
Changes from 31 commits
855985d
40fdb05
9670da2
3ffc870
8139f78
0a94650
d0f6d23
6c76161
ad3d926
e097a87
5ff3a32
fcbda15
3175b34
515fb9f
c7d6fcf
5911cc3
47ca7fc
d0ee9c5
c75ab23
32ed22c
e629b2a
89de406
1d13f4a
479b761
01e8d74
6762b21
eae7716
fba641f
06b7cdb
39c746b
af170e1
4c9bc9f
c59d29f
0db8838
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not especially familiar with melt and multi-index columns, but I don't think this is quite right.
It seems like you need to specify
col_level
when you have a MI in the columns, so you should probably just be checks againstframe.columns.levels[col_level]
when you have a MI.However, it doesn't quite seem that a
col_level
is required when there's a MI in the columns. The default ofpd.melt(df)
seems to work, but any time I specified anid_vars
orvalue_vars
without col_level I get an uninformative error message. I'm not sure what's going on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to provide
col_level
for MI when only melting on one level like this example from the docstring (that I added a new test for):pd.melt(df, col_level=0, id_vars=['A'], value_vars=['B'])
But you don't need to specify
col_level
when using all levels of MI:pd.melt(df, id_vars=[('A', 'D')], value_vars=[('B', 'E')])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All I am doing at L28 is gathering column names from all levels. There are other checks to make sure that melting is performed properly, this will just check to make sure that whatever you pass, it is in your df
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think this is ok, can you provdie a comment on what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you do an example with an MI and columns that are not in the top level of the MI, ideally try with and w/o col_level as well.