I am trying to load this file using genfromtxt and count missing values in each column
below is my code:
import numpy as np
data = np.genfromtxt(datafile, delimiter=",", names=["col1","col2","col3","col4","col5","col6"], dtype=None, encoding='ascii')
missing_values = np.isnan(data)
but it gives me below error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-120-a4d778701252> in <module>
----> 1 missing_values = np.isnan(data)
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

The problem is that
np.isnanworks only withfloat; but when you usenamesingenfromtxt, you complicate thedtype:The easiest way is to use
genfromtxtwithout column names (as dtypefloat), and then count thenanvalues: