我的数据如下。
dim3 threadsPerBlock(8, 8);
dim3 grid(targetAreaRect_px._uiWidth / threadsPerBlock.x, targetAreaRect_px._uiHeight / threadsPerBlock.y);
CudaTransformAndAverageImage << < grid, threadsPerBlock >> > (pcPreRasteredImage_dyn, resultArray );
代码是
data
62600.0
63000.0
62900.0
60400.0
59800.0
3.错误消息
def Simplify(G_x,data):
data['dx'] = data*G_x
data['dy'] = data - data.shift(1)
data = data.fillna(0)
data['G_mag'] = np.sqrt((data['dx']+data['dy'])*(data['dx']+data['dy'])-2*data['dx']*data['dy'])
data['Theta'] = np.arctan(data['dy']/data['dx'])
data = data.fillna(0)
data['Theta']=0
data.loc[data['Theta']<0,'Theta'] = data['Theta']+2*np.pi
data.loc[(data['Theta']<=np.pi/8) & (data['Theta']>=0), 'Theta'] = np.arctan(0)
data.loc[(data['Theta']<=3*np.pi/8) & (data['Theta']>1*np.pi/8), 'Theta'] = np.arctan(1)
data.loc[(data['Theta']<=np.pi) & (data['Theta']>3*np.pi/8), 'Theta'] = np.arctan(2)
data.loc[(data['Theta']<=13*np.pi/8) & (data['Theta']>np.pi), 'Theta'] = np.arctan(-2)
data.loc[(data['Theta']<=15*np.pi/8) & (data['Theta']>13*np.pi/8), 'Theta'] = np.arctan(-1)
data.loc[(data['Theta']>15*np.pi/8) & (data['Theta']<=2*np.pi), 'Theta'] = np.arctan(0)
data['New_dy'] = data['dx']*np.tan(data['Theta'])
data['N_AC']=data['New_dy'].cumsum()+data['Adj Close'][0]
return data['N_AC']
4。当我直接运行此代码时,不使用函数。它运作良好。 有没有什么好方法可以解决这个问题。谢谢!
答案 0 :(得分:1)
您可能已经在某处创建了一个名为np
的全局变量,因此当您编写np.sqrt
或np.arctan
时,它会尝试查找对象np
的相应方法调用numpy函数。
或者当你不将它用作函数时,它必须是因为它在函数中不理解np
表示包numpy
。如果您正在处理笔记本电脑,例如jupyter,只需在您正在使用的笔记本中添加import numpy as np
。如果您只在您调用该功能的笔记本中加载numpy
,它将无法理解np
指的是什么。