我有followig pandas df,
Price Generic
0 3.5 3
1 2 4
3 3.4 23
我想用日志值创建新列:
import numpy as np
df["log Price"]=np.log(df["Price"])
但不起作用,错误是:
AttributeError: 'Series' object has no attribute 'float'
我尝试将类型转换为float:
df['Price'] = df['Price'].float()
**AttributeError**: 'Series' object has no attribute 'float'
谢谢!
答案 0 :(得分:0)
转换应像这样完成:
df['Price'] = df['Price'].astype('float64')