Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

download csv file from jupyter notebook

import base64
import pandas as pd
from IPython.display import HTML

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)

df = pd.DataFrame(data = [[1,2],[3,4]], columns=['Col 1', 'Col 2'])
create_download_link(df)
Comment

PREVIOUS NEXT
Code Example
Python :: set points size in geopandas plot 
Python :: square a number in python 
Python :: fillna not work 
Python :: Django how to get url path for a view 
Python :: ip validity checker python 
Python :: chatbot using python github 
Python :: django start app 
Python :: activate venv 
Python :: associate keys as list to values in python 
Python :: get array dimension numpy 
Python :: python enumerate for loop 
Python :: sys.maxsize in python 
Python :: webdriverwait python 
Python :: python code execution time 
Python :: multiplication table python 
Python :: Python write value in next row of existing .text file 
Python :: how to make timer in python 
Python :: vscode python workding directory 
Python :: Highlight Active Links in Django Website 
Python :: 2d array in python 
Python :: how to install package offline 
Python :: random.uniform python 
Python :: change the side of the axis plt python 
Python :: append element an array in python 
Python :: private instance attribute python 
Python :: valid parentheses 
Python :: seaborn color palette python 
Python :: pandas dataframe add two columns int and string 
Python :: add a new column to numpy array 
Python :: pandas write csv 
ADD CONTENT
Topic
Content
Source link
Name
9+3 =