4 回答

TA贡献1993条经验 获得超5个赞
你有没有尝试过
clean_df.to_csv(folder_to_export_path+'/filename.csv')
或者如果使用 python 3.6+
clean_df.to_csv(f'{folder_to_export_path}/filename.csv')

TA贡献1911条经验 获得超7个赞
您的最后一行有语法错误,请尝试使用以下内容更正它:
clean_df.to_csv(folder_to_export_path+'/filename.csv')

TA贡献1799条经验 获得超9个赞
首先,使用to_csv您需要传递文件路径(或文件对象)。所以这使你folder_to_export_path='http://20.9.6.11:8066/file_info/products/processed_file'
无效。
应该 folder_to_export_path = 'file_info/products/processed_file/filename.csv'
假设您要导出目录中的 CSV file_info/products/processed_file
。
其次,to_csv
可以创建一个名为 file 的文件filename.csv
,如果它不存在但不能创建目录。
要创建不存在的目录然后保存文件,您可以执行以下操作:
import os
import pandas as pd
folder_to_export_path = 'file_info/products/processed_file/'
if not os.path.exists(folder_to_export_path):
os.makedirs(folder_to_export_path)
pd.to_csv(os.path.join(folder_to_export_path, 'filename.csv'))
那应该有效。

TA贡献1868条经验 获得超4个赞
尝试这个:
folder_to_export_path = "http://20.9.6.11:8066/file_info/products/processed_file/"
clean_df.to_csv(folder_to_export_path+'filename.csv')
参考:这里
添加回答
举报