I have a dataframe that looks a little bit like this
A B C D E F G H
100 100 NaN 100 1000 NaN NaN NaN
I'm trying to count the instances of NaN in columns A-D; and then columns E-H
What I've tried is:
df_["NaN_A-D"] = df[["A", "B", "C", "D"]].isna().sum()
df_["NaN_E-H"] = df[["E", "F", "G", "H"]].isna().sum()
But the new column just returns NaN rather than summing up the instances of NaN (ie 1 for the first grouping and 3 for the second grouping.
What am I doing wrong, please?
Thanks