task.py
Figure 2 使用csv file傳遞校正答案
import pandas as pd
import os
cwd = os.getcwd() + os.sep
root_dir = cwd.replace(os.sep + 'codes' + os.sep,'')
answer_M_folder = 'Answer_M'
if not os.path.isdir(os.path.join(root_dir, answer_M_folder)):
os.makedirs(os.path.join(root_dir, answer_M_folder))
### You must Modified ###
out_csv_filename = 'task1.csv'
ID=[379, 442, 702, 713, 717, 915, 1106, 1193, 1254, 1520]
answer = [1, 3, 4, 1, 2, 2, 3, 1, 4, 1]
### You must Modified ###
answer_dict = {"ID": ID, "answer": answer}
df = pd.DataFrame(answer_dict)
print(df)
dst = os.path.join(root_dir, answer_M_folder, out_csv_filename)
df.to_csv(dst)
Realization
- 用spyder開啟
task.py
- 執行
task.py
- running setting for
task.py
- 在ipython console顯示執行結果
- 執行完
task.py
後kaggle2_answer_M
會新增answer_M
資料夾以及csv檔