python - 如何在 pandas 中使用 to_csv 函数时解决分隔符错误
问题描述
这是关于如何逐个单元格编写单行单元格并将其填充到 csv 文件中的后续问题
import pandas as pd
delim = "@@@"
# just for abrevation
tmp = pd.read_csv("mycsv.csv",sep='@@@')
tmp.loc[0,:] = "None"
tmp.to_csv("mycsv.csv",sep=delim,index=False)
我收到跟随错误。请提出一些正确的解决方案
self.writer = csv.writer(f, **writer_kwargs)
TypeError: "delimiter" must be a 1-character string
Exception ignored in: <module 'threading' from
Traceback (most recent call last):
line 1296, in _shutdown
_main_thread._delete()
File /share/python-3.6.1/linux_x86_64/lib/python3.6/threading.py", line 1015,
in _delete
del _active[get_ident()]
KeyError: 140613724829696
解决方案
推荐阅读
- php - 如何在 Typo3 9 中检查应用程序上下文?
- php - 代码中的 trans 函数是什么意思……以及 quickadmin 类的位置
- java - JAVA RMI 加法示例
- javascript - 如何从这些属性中构造一个新对象?
- sql - sql 使用来自另一个表的信息更新列,其中链接列重复
- php - 无法在 SELECT 字段名称中使用 BindValue?
- wordpress - 使用用户名、电子邮件和自定义元字段的 Wordpress 登录
- c++ - “for(;;)”的目的是什么
- mysql - MySQL 触发器 - 比较两个不同表的值
- python - IndexError:在 TensorFlow 中列出超出范围的索引