import pandas
from decimal import Decimal
base_data = pandas.DataFrame(data = {'name':'Sarah', 'balance': Decimal(1)}, index = [0])
## drop the first row and aggregate
summary_data = base_data.drop(0).groupby('name').agg({'balance' : 'sum'})
summary_data.balance.dtype
收益率
dtype('float64')
而不是应该的Decimal
或dtype('O')
。你知道吗
这个问题会在以后的代码中导致一个类型错误,当我执行左连接时,用零填充,并尝试向float64(64)中添加另一个十进制数。你知道吗
用
astype
重铸数据帧相关问题 更多 >
编程相关推荐