-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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
Bug in set_index or drop #2101
Comments
Garbage indeed. MO <--> #2064 df.drop(df.index[df['var1'].isin(drop_idx)])
var1 var2 var3 var4
0 x-a x a 1.5
1 x-a x a 1.2
2 z-c z c 3.1
3 x-a x a 4.1
4 x-b x b 5.1
5 x-b x b 4.1
6 x-b x b 2.2
7 y-a y a 1.2
8 z-b z b 2.1 |
Ah, nice one-liner. Missed your comment on my other issue. |
@changhiskhan indeed! In [55]: drop_idx
Out[55]:
var1
y-a 1
z-b 1
z-c 1
In [56]: s = pd.Series(['y-a', 1])
In [57]: s.isin(drop_idx)
Out[57]:
0 False
1 True
In [59]: for x in ['y-a', 1]:
....: print x, x in drop_idx
....:
y-a True
1 False |
I think Skipper's code should work. I'll have a look |
Maybe you can just call take instead of reindex and get around the non-uniqueness problem. |
It's a bit quick-and-dirt but it gets the job done |
I'm not sure if the bug is in the drop or that it shouldn't have let me set this MultiIndex since it's non-unique. var1 is just a combination of var2 and var3. In any event the result given back by this is garbage. I wanted to drop all the rows where the count of var1 == 1. Since there's not to my knowledge a way to drop variables without setting them to an index, I tried to do this without thinking
The text was updated successfully, but these errors were encountered: