So, I've got a df like so,
ID,A,B,C,D,E,F,G
1,123,30,3G,1,123,30,3G
2,456,40,4G,NaN,NaN,NaN,4G
3,789,35,5G,NaN,NaN,NaN,NaN
I also have a list that has a subset of the header list of df like so,
header_list = ["D","E","F","G"]
Now I'd like to get those records from df that CONTAINS Null values FOR ALL OF the Column Names in the header_list.
Expected Output:
ID,A,B,C,D,E,F,G
3,789,35,5G,NaN,NaN,NaN,NaN
I tried,
new_df = df[df[header_list].isnull()] but this throws error, ValueError: Boolean array expected for the condition, not float64
I know I can do something like this,
new_df = df[(df['D'].isnull()) & (df['E'].isnull()) & (df['F'].isnull()) & (df['G'].isnull())]
But I don't want to hard code it like this. So is there a better way of doing this?