Skip to content
Advertisement

How to filter column names from multiindex dataframe for a specific condition?

JavaScript

How to filter level[0] column name list where comparions = False from the dataframe df_final(consider there are more than 300 column like this at level 0)

enter image description here

Advertisement

Answer

First test if in level comparions are all Trues by DataFrame.xs with DataFrame.all:

JavaScript

And then invert mask for test at least one False with filter indices:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement