I have the following pandas dataframe;
a = [['01', '12345', 'null'], ['02', '78910', '9870'], ['01', '23456', 'null'],['01', '98765', '8760']]
df_a = pd.DataFrame(a, columns=['id', 'order', 'location'])
I need to get a count of how many NULL values (NULL is a string) that occur for each ID. So the result would look like;
id null_count
01 02
I can get basic counts using a groupby:
new_df = df_a.groupby(['id', 'location'])['id'].count()
But the results return more than just the NULL values;
id location
01 8760 1
null 2
02 9870 1