Selecting Rows - Based On A List - From A Df With Duplicated Columns
I have the following Data frame: import pandas as pd rep = pd.DataFrame.from_items([('Probe', ['x', 'y', 'z']), ('Gene', ['foo', 'bar', 'qux']), ('Probe',['x','y','z']), ('RP',[1.
Solution 1:
You should use iloc here:
In[11]: rep.iloc[rep.iloc[0].isin(ls).values]
Out[11]:
ProbeGeneProbeRP0xfoox1.02zquxz4.5
This first creates the boolean vector (as a one-dimensional array rather than a DataFrame), and you can use this as a mask:
In [12]: rep.iloc[0].isin(ls).valuesOut[12]: array([ True, False, True, False], dtype=bool)
Post a Comment for "Selecting Rows - Based On A List - From A Df With Duplicated Columns"