【发布时间】:2021-08-28 13:06:20
【问题描述】:
df1 = pd.DataFrame(listoflists, columns =['size', 'text'])
我将 listoflists 转换为两列 pandas df1
listoflists = [[10.5, 'qqqqq \t\n'], [11.0, 'rrrreee \n'], [10.5, 'rrrrr \n'], [10.000000000000057, 'ertttt \n'], [7.500000000000007, 'ert: ert \n']]
col size 自动四舍五入。我怎样才能防止熊猫这样做?我想保留所有小数。
print(df1)
size text
0 10.5 qqqqq \t\n
1 11.0 rrrreee \n
2 10.5 rrrrr \n
3 10.0 ertttt \n
4 7.5 ert: ert \n
我试过了
df1.style.format({
'size': '{:,.3f}'.format})
但这并没有帮助
【问题讨论】:
标签: python-3.x pandas dataframe rounding