Hi Sarah,
Alexander is giving good direction.
I however think the hint from the assignment is a bit misleading and isn’t teaching idiomatic pandas. All pandas DataFrame operations are performed per column, by default, as pandas uses a column major layout for data. Let me elaborate below.
For example, there is a method isnull on the DataFrame itself. pandas.DataFrame.isnull — pandas 1.5.0 documentation
There will return you a DataFrame where each element is true or false, true if the element is numpy.nan false otherwise. To get the sum of each column I would look at pandas.DataFrame.sum which will perform a summation on each column. pandas.DataFrame.sum — pandas 1.5.0 documentation
Note that true values are counted as a 1, and false as a zero.
This will yield the number of null values in each column. The resultant object should be a pandas.Series which too has a sum method that will sum the values of the series.
You are very close in your answer. You have the number of null values per column but not the total for the entire DataFrame. You’re missing one step.
You could have your answer in 1 line…
pandas.DataFrame.isnull().sum().sum()