【发布时间】:2021-09-22 11:37:29
【问题描述】:
我有一张 pandas 表,我想做以下数学运算:
|label| area | equivalent_diameter| mean_intensity| solidity|
---------------------------------------------------------------
1 1011 35.878199 255.0 0.863365:
2 107 11.672045 255.0 0.849206
3 8 3.191538 76.0 0.800000
4 18 4.787307 255.0 0.720000
5 110 11.834541 255.0 0.769231
----------------------------------------------------------------
基本上我想:
df['area'] = math.sqrt(df['area]/math.pi)
TypeError: cannot convert the series to <class 'float'>
我做了什么并没有解决问题:
new_data = df['area'].apply(lambda x: float(x))
# and then:
new_x = new_data/math.pi
new_y = math.sqrt(new_x)
仍然报同样的错误。
【问题讨论】:
标签: python-3.x pandas dataframe