Given the df
df=pd.DataFrame([[0.23,"A1",10],[5.36,"A2",55],[8.8,"A3",4]],
index=list('pqr'),
columns=list('abc'))
And the following list
lst = ['A30','A50','A2','A0']
I would like to print the rows from the DF which values matches any of the values within the list, for the df and list above I would expect the output to be something like
Out[169]:
a b c
q 5.36 A2 55
But the closest I've got is this
mask=df.isin(lst)
df[mask].dropna(axis=0,how="all")
Out[170]:
a b c
q NaN A2 NaN
The 'NaN' are result of doing "df[mask]" but I don't understand why neither if I'm doing right to get the output I want to.
Is there a way to achieve the output sample I mentioned above/next ?
Out[169]:
a b c
q 5.36 A2 55