【发布时间】:2022-11-02 21:15:19
【问题描述】:
我有一个 DF,我需要计算两个南北风分量的反正切值。但是,根据文档,arctan2 函数似乎只需要 2 个参数 x,y :
numpy.arctan2(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'arctan2'>
但是,我需要除以 x、y 分量以获得我想要的答案。所以,我需要这样做——
dfout = np.arctan2(x/y) 使用 1 个参数,但文档说我需要 2 个参数 x,y。
我将“/”符号视为一个选项,但我不确定这是否适用或如何做到这一点。有任何想法吗?
我的数据在 df 中如下所示:
day hour Cns Cew
1 0 126.002 -100.812
1 1 -42.3775 18.6631
1 2 64.3313 -121.167
我需要在上面的示例中执行此操作:
dfout = np.arctan2(df.Cew/df.Cns)
但我得到这个错误 -
TypeError: arctan2() takes from 2 to 3 positional arguments but 1 were given
我已经尝试过了,但出现语法错误。
dfout = np.arctan2(df.Cew,df.Cns,/)
非常感谢,
【问题讨论】:
标签: python pandas math trigonometry