Pandas Select DataFrame columns using boolean

后端 未结 5 842
我在风中等你
我在风中等你 2020-12-30 23:05

I want to use a boolean to select the columns with more than 4000 entries from a dataframe comb which has over 1,000 columns. This expression gives me a Boolean

5条回答
  •  抹茶落季
    2020-12-30 23:29

    Another solution is to transpose comb to make its columns act as its index, then transpose on the resulting subset:

    comb.T[criteria].T
    

    Again, not particularly elegant, but at least shorter/less repetitive than the leading solution.

提交回复
热议问题