Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有数据框,我想为每一行计算 10^(0.13*df['value']) 并将结果保存到新列。
东风:
价值 | 价值2
22 12 22 33
我想在列 value2 中保存结果,例如:第一行 10^(-0.13*22)。
我试过:
df['value2'] = math.pow(10, -0.13*df['value'])
类型错误:无法将系列转换为“浮点”类
python函数math.pow期望第二个参数是float类型,因为你想计算你系列中每个元素的功率,你应该使用numpy包,所以可以试试
import numpy as np np.power(10, -13 * df['value'])