测试Kaggle kernel commit 是否会删除以前的output

 

在kaggle上创建kernel,加入如下代码。

连续运行两次,可以看到保存的文件名字不一样,且无论运行错少次,都只有一个输出文件。

这说明,kaggle上的kernel每次commit运行,都会清空输出文件。

# This Python 3 environment comes with many helpful analytics libraries installed
# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python
# For example, here's several helpful packages to load in 
import numpy as np # linear algebra
import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

df = pd.DataFrame({'name':   ['Raphael', 'Donatello'],
                   'mask':   ['red',     'purple'   ],
                   'weapon': ['sai',     'bo staff' ]})
df.to_csv(index=False)
    

import time

def get_now_time_string():
    return time.strftime("%Y%m%d_%H%M%S",time.localtime())

file_name = get_now_time_string() + '.csv'
df.to_csv(file_name)
print(file_name, 'saved.')

 

转载于:https://www.cnblogs.com/xbit/p/10504867.html

你可能感兴趣的:(python)