[Solved] How do I filter an empty DataFrame and still keep the columns of that DataFrame?


df2 = df1[df1.B.apply(lambda x:x == 1).astype(bool)]

All other answers are missing the point (except for Wen’s, which is an ok alternative)

1

solved How do I filter an empty DataFrame and still keep the columns of that DataFrame?