Groupby class and count missing values in features

前端 未结 3 919
慢半拍i
慢半拍i 2021-01-17 07:16

I have a problem and I cannot find any solution in the web or documentation, even if I think that it is very trivial.

What do I want to do?

I have a datafram

3条回答
  •  遇见更好的自我
    2021-01-17 08:04

    You can use set_index and sum:

    df.set_index('CLASS').isna().sum(level=0)
    

    Output:

           FEATURE1  FEATURE2  FEATURE3
    CLASS                              
    X           1.0       1.0       2.0
    B           0.0       0.0       0.0
    

提交回复
热议问题