#def u(x, y):
# if x<=90:
# uwnd=y*np.sin(x*np.pi/180)
# if x>90 and x<=180:
# uwnd=y*np.sin((180-x)*np.pi/180)
# if x>180 and x<=270:
# uwnd=-y*np.sin((x-180)*np.pi/180)
# if x>270 and x<=360:
# uwnd=-y*np.sin((360-x)*np.pi/180)
# return (uwnd)
#def v(x, y):
# if x<=90:
# vwnd=y*np.cos(x*np.pi/180)
# if x>90 and x<=180:
# vwnd=-y*np.cos((180-x)*np.pi/180)
# if x>180 and x<=270:
# vwnd=-y*np.cos((x-180)*np.pi/180)
# if x>270 and x<=360:
# vwnd=y*np.cos((360-x)*np.pi/180)
# return (vwnd)
#df['u'] = df.apply(lambda x: u(x.direction, x.speed), axis = 1)
#df['v'] = df.apply(lambda x: v(x.direction, x.speed), axis = 1)
或者
df['u'] = df.apply(lambda x: x['speed'] *math.sin((180-x['direction'])*np.pi/180), axis=1)
df['v'] = df.apply(lambda x: x['speed'] *math.cos( x['direction']*np.pi/180), axis=1)