I have 2 pandas dataframes.
>>> df1
col1 col2
sec1 11 22
sec2 11 22
sec3 11 22
>>> df2
col1 col2
sec1 False False
sec2 False True
sec3 False False
If a column in df2 has at least one True, then the column with the same header in df1 should be removed.
So in this example, the expected output should be
>>> df1
col1
sec1 11
sec2 11
sec3 11
Here is my Python code
import pandas as pd
df1 = pd.DataFrame({'cond1': [11, 11, 11], 'cond2': [22, 22, 22]}, index=['sec1', 'sec2', 'sec3'])
df2 = pd.DataFrame({'cond1': [False, False, False], 'cond2': [False, True, False]}, index=['sec1', 'sed2', 'sec3'])
ds_remove = df2.any(axis=0)
df1.drop(ds_remove, inplace=True) # This line does not work.
Could you please help me?
Thanks