美文网首页
kaggle kernel无需commit直接下载run保存的文

kaggle kernel无需commit直接下载run保存的文

作者: ibunny | 来源:发表于2019-07-18 15:09 被阅读0次

    方法一

    在Markdown单元格添加下载链接

    <a href="your_file_name.csv"> Download File </a>
    

    方法二

    # import the modules we'll need
    from IPython.display import HTML
    import pandas as pd
    import numpy as np
    import base64
    
    # function that takes in a dataframe and creates a text link to  
    # download it (will only work for files < 2MB or so)
    def create_download_link(df, title = "Download CSV file", filename = "data.csv"):  
        csv = df.to_csv()
        b64 = base64.b64encode(csv.encode())
        payload = b64.decode()
        html = '<a download="{filename}" href="data:text/csv;base64,{payload}" target="_blank">{title}</a>'
        html = html.format(payload=payload,title=title,filename=filename)
        return HTML(html)
    
    # create a random sample dataframe
    df = pd.DataFrame(np.random.randn(50, 4), columns=list('ABCD'))
    
    # create a link to download the dataframe
    create_download_link(df)
    
    # ↓ ↓ ↓  Yay, download link! ↓ ↓ ↓ 
    

    相关文章

      网友评论

          本文标题:kaggle kernel无需commit直接下载run保存的文

          本文链接:https://www.haomeiwen.com/subject/swsllctx.html