![](/img/trans.png)
[英]find a value in a dataframe and add precedent column value in a new column in pandas
[英]How to add new column to Pandas dataframe with log value
我有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'
我尝试将类型转换为浮动,使用:
df['Price'] = df['Price'].float()
**AttributeError**: 'Series' object has no attribute 'float'
谢谢!!!
转换应该像这样完成:
df['Price'] = df['Price'].astype('float64')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.