juypter
weekly_return 是list

要求必须用到lambda和map
代码如下
import numpy as np
weekly_return = list(weekly_return)
weekly_return_without_NaN = list(map(lambda x:weekly_return.remove(x) if True in np.isnan(x) else x, weekly_return[:]))
出现以下错误
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-95-2d30654257b9> in <module>
12 from scipy.stats import normaltest
13 weekly_return = list(weekly_return)
---> 14 weekly_return_without_NaN = list(map(lambda x:weekly_return.remove(x) if True in np.isnan(x) else x, weekly_return[:]))
15
16 print("ttt1")
<ipython-input-95-2d30654257b9> in <lambda>(x)
12 from scipy.stats import normaltest
13 weekly_return = list(weekly_return)
---> 14 weekly_return_without_NaN = list(map(lambda x:weekly_return.remove(x) if True in np.isnan(x) else x, weekly_return[:]))
15
16 print("ttt1")
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''