I have dataframe with many columns and I want to create table with one consistent column and two other columns that are changing in each loop.
The problem is that the first step of the slicing fails and I don't manage to create this new 3 columnns dataframe.
#list of pairs of the columns i'm interested in for each loop
cols_of_interest=[['col1', 'col2'],['col3','col4']]
for i in cols_of_interest:
table=df[df[['col_not_from_list',i[0],i[1]]]]
table = table.dropna(how='any',axis=0)
...
----> 7 table=df[df[['col_not_from_list',i[0],i[1]]]]
ValueError: Boolean array expected for the condition, not float64
Older posts regard this same error mention that the version of pandas might be the problem but I don't think is this case (as those posts are fro mserveral years ago). In addition I found tip of using mask instead but I don't understand why slicing it this way would not work.
My end goal: to create dataframe inside the loop with three column: the consistent +the two other from the list.