4 回答

TA貢獻1993條經驗 獲得超6個贊
你有沒有嘗試過
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')
參考:這里
添加回答
舉報