I prepared the test data as follows:
np.random.seed(0)
df = pd.DataFrame(np.random.random(size=(5, 10)), columns=list('ABCDEFGHIJ'))
df[df > 0.9] = pd.np.nan; df
To get column names containig NaN values, run:
nn = df.isnull().any()
For my test data, the result is:
A True
B False
C False
D True
E False
F False
G False
H True
I True
J False
dtype: bool
We are actually interested in index values where the value is True.
To get them, run:
nullCols = nn.index[nn].tolist()
The result is:
['A', 'D', 'H', 'I']
And to get the number of such columns, run:
len(nullCols)
The result is 4
.