Its always what seems easy, that torment me. I am trying to get a count of the number of non-zero values ββof some variables in a Dataframe, grouped by month and year. So I can do it that works great
counts_by_month=df[variable1, variable2].groupby([lambda x: x.year,lambda x: x.month]).count()
But I REALLY want to know how many of these values ββin each group are NaN. Therefore, I want to count Nans in each variable too, so that I can calculate the percentage data that is not in each group. I can not find a function for this. or maybe I could get to the same end by counting the total number of elements in the group. Then NaNs will be Total - "Non-Null values"
I tried to find out if I can somehow calculate the index values, but I could not do it. Any help on this is greatly appreciated. Best regards jason
source share