I am looking to apply multiply masks on each column of a pandas dataset (respectively to its properties) in Python.
In the next step, I want to find (a) row(s) in the dataframe that fits all conditions.
Therefore I have:
df
Out[27]:
DE FL GA IA ID
0 0 1 0 0 0
1 1 0 1 0 1
2 0 0 1 0 0
3 0 1 0 0 0
4 0 0 0 0 0
mask_list = []
for i in range(0,5):
if i % 2==0:
mask_list.append(df[[i]]>0)
else:
mask_list.append(df[[i]]<1)
concat_frame = pa.DataFrame()
for mask in mask_list:
concat_frame =pa.concat((concat_frame, mask), axis=1)
concat_frame
Out[48]:
DE FL GA IA ID
0 False False False True False
1 True True True True True
2 False True True True False
3 False False False True False
4 False True False True False
[5 rows x 5 columns]
Expected outcome:
Out[60]:
DE FL GA IA ID
1 1 0 1 0 1
How can I apply the concat_mask on df, so that I select rows, in which all Boolean criteria are matched (are True)?