python - Why is pandas DataFrame.to_csv float_format option using the old-style formatting?
问题描述
I wanted to write a pandas DataFrame into a CSV. I wanted all floats to have 2 decimal points. So I used the new formatting style of Python:
indf.to_csv("myfile.csv", float_format="{:.2}")
But no, apparently to_csv
wants the old formatting style
indf.to_csv("myfile.csv", float_format="%.2f")
Why is that?
解决方案
目前正在讨论这个问题。看看https://github.com/pandas-dev/pandas/issues/9448
推荐阅读
- cryptography - 区块链密钥对私钥是如何对矿工隐藏的,它们是如何生成的?
- microservices - 为应该在特定时间间隔内发生的活动触发警报(使用 Prometheus Metrics 和 AlertManager)
- reactjs - React-router 链接更改 URL ID 但组件未重新加载
- amazon-web-services - AWS cloudformation:创建 AWS::ElastiCache::ReplicationGroup 资源时如何设置集群名称
- python - 用于 VGG19 模型参数的 Tensorflow Float16
- sql - 在将新文件主动写入源目录时,如何安全地将文件导入 ssis 中的 sql server?
- r - 根据列表过滤数据帧,然后根据所述过滤器保存每个数据帧。是创建一个函数还是 for 循环要走的路?
- amazon-web-services - 标签包含括号时如何搜索过滤器
- python - 如何正确使用缩放器模型?
- c# - 使用相同的 webdriver 实例