Hello,
in the UNQ_C1 cell, we are expected to write code that computes the fraction of missing values. This can be achieved by:
df.isnull().any(axis = 1).sum() / df.shape[0]
However, one of the test cases is returning an error related to “Wrong shape”. This can be overcome by simply putting the code inside the funciton float(). That is:
float(df.isnull().any(axis = 1).sum() / df.shape[0])
This way the funciton returns the value as a float rather than an np.float
4 Likes
Hi, @VALID_HUSEYIN
It may help you to check the data type of df.isnull().any(axis = 1).sum()
and df.shape[0]
by the type() function.
I hope you could confirm that the data type of df.shape[0]
is int, whereas that of df.isnull().any(axis = 1).sum()
is pd.Series.
This is the reason why you encounter the error related to “wrong shape”.
In the UNQ_C1, we would like to know how many missing values in df, so you should count it and get the integer data type.
Kind regards,
Nakamura
5 Likes
This is not correct, df.isnull().any(axis = 1).sum()
is an np.int64. The behavior of the test is not correct.