-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
subset keyword argument will include last column if incorrect keys are given #8303
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
Comments
yep would call that a buggy....pull-request welcome! |
Would it be best for |
no this is very easy to fix |
Easy enough, but does this mean we don't support location based indices for the |
only support labels - you have the whole complication the of having to have 2 methods to disambiguate and get indexer converts labels to locations |
use your example (with subset = [-1]) as a test |
Yes, I like just supporting column labels here. I do note though, that when I do this
I get this (i.e. it works as if it was dropping rows where the last were nan)
|
the indexer returns -1 (meaning it can't find the key) and take returns the last value so you will need to filter out -1 or maybe if any -1 should raise we usually do this (eg in loc) though I think in this case prob should just a raise of any columns are not found |
As far as raising an error goes, I was using subset specifically because I didn't care which of It's a feature that could (and probably should) be reproduced by a more general function, but would be missed (by me at least) if it was removed without replacement. It's worth noting |
I wouldn't mind doing this, but I've never developed for a large project and so might have problems with some aspects like
If you're still interested in having me contribute, can someone please point me to where I can get help with these sorts of issues. |
oh, @mcjcode already has a soln (to this immediate problem). love to have contributions, see here for more info (and windows section on how to built for that). All of the above are covered. Start and issue and lmk when you need help! |
Just to throw in an edge case: column label -1. Subset arg is clear (we can ignore positions):
|
If you give a non-existent key to the subset argument it will default to the last column. For example:
It seems the problem is in the line where dropna takes the subset:
Here,
ax.get_indexer_for(subset)
will return-1
as a sentinel value for any keys that were not found insubset
, andself.take
interprets the-1
as a request for the last column.The text was updated successfully, but these errors were encountered: