【发布时间】:2019-01-14 13:24:36
【问题描述】:
根据文档(https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_csv.html),我们可以在dataframe的to_csv方法中指定浮点数格式。
我尝试使用float_format=':,.2%' 参数将浮点格式更改为2 个小数百分比,该参数适用于python 控制台(如'{:,.2%}'.format(3.14)),但to_csv 给出“格式不完整”错误。
【问题讨论】: