Skip to content
Advertisement

Pandas groupby column and sum nulls of all other columns

I have a dataframe with the following structure:

JavaScript

I’d like to know, grouping by group, how many nulls there are in each column.

In this case, the output should be:

JavaScript

I don’t have control on how many columns I have or their names. Thanks!

Advertisement

Answer

Convert column group to index, test all another values for misisng values by DataFrame.isna, and for count Trues aggregate sum:

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