mgokhanbakal
mgokhanbakal

Reputation: 1727

Masking a pandas dataframe object

I am trying to run the following code but I am getting the error message like "TypeError: The numpy boolean negative, the - operator, is not supported, use the ~ operator or the logical_not function instead."

I am getting the error when the line np_mask = A_df_masked.notnull() is runned.

How can I fix this issue?

Thanks in advance.

A_orig = np.array([[3, 4, 5, 2],
                   [4, 4, 3, 3],
                   [5, 5, 4, 4]], dtype=np.float32).T

A_orig_df = pd.DataFrame(A_orig)

#masking some of the entries
A_df_masked = A_orig_df.copy()
A_df_masked.iloc[0,0]=np.NAN

np_mask = A_df_masked.notnull()

The desired output of np_mask will be:

    0       1       2
0   False   True    True
1   True    True    True
2   True    True    True
3   True    True    True 

Upvotes: 0

Views: 284

Answers (1)

jakevdp
jakevdp

Reputation: 86328

This is an incompatibility between older versions of Pandas and newer versions of NumPy (Reported in this issue) If you update pandas to a more recent version, the problem should be fixed.

Upvotes: 2

Related Questions