我有一些numpy.ndarray变量。它们包括nan值,我想从中删除每个nan值。数组包含int,float,str等值。这些数组的示例:
['A' 'B' 'C' 'D' nan 'E' 'F']
另一个:
[nan 1.]
在某些情况下,数组可能包含float,str和nan值。在这种情况下,如何只删除nan值?
我使用了以下代码:
x[:,~np.isnan(x).any(axis=0)]
并出现以下错误:
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''