数据帧列如下所示:
VALUE
1
2
3
4
5
...
40
我想为eah值生成两个新列,如下所示:
df['VALUE1'] = math.cos(df['VALUE'] * 2 * math.pi / 48)
df['VALUE2'] = math.sin(df['VALUE'] * 2 * math.pi / 48)
但是我的脚本崩溃了,没有错误
结果应该是这样的:
VALUE VALUE1 VALUE2
1 ... ...
2 ... ...
3
4
5
...
40 ... ...
有什么问题吗
Tags:
math.sin
和math.cos
不接受序列。使用numpy
,向量方法很快你可以使用
apply
,但它们往往很慢你试过申请吗
使用Numpy函数,因为它们可以处理向量(列),而不是
math
相关问题 更多 >
编程相关推荐