2024-09-27 00:20:29 发布
网友
我有一个带有一堆混乱文本数据的df。它看起来像这样:
name email John Doe jdoe@gmail.com Anthony Fiorella\nPhD afiorella@gmail.com Xu "Chris" Chang xcchang@hotmail.com
我尝试了一些方法来删除转义字符,比如
df = df.replace(r'\\n',' ', regex=True)
但到目前为止,一切都不起作用
您可以使用以下代码:
df["name"].replace(to_replace=r"\n", value=" ", regex=True, inplace=True)
正式文件中提供了补充资料:pandas.DataFrame.replace
您可以使用以下代码:
正式文件中提供了补充资料:pandas.DataFrame.replace
相关问题 更多 >
编程相关推荐