Issue
I have pandas frame F
and numpy ndarray a
, of dimensions m x n and m x 1 respectively. a
contains only 1's and 0's and I'm trying to get a new pandas frame that are the rows of F
for which a
is 1.
I tried F2 = F[a,:]
and F2 = F[a.tolist(),:]
, neither of which was successful. How do I tackle this please?
Solution
IIUC, going for boolean indexing with loc
should do:
F.loc[a.astype(bool)]
Answered By - Mustafa Aydın
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.