Created
February 11, 2020 00:08
-
-
Save wesleyegberto/f0883b0390af33c1da4b5ef9f9b716d6 to your computer and use it in GitHub Desktop.
Function to download a Pandas dataframe from a Jupyter notebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def csv_download_link(df, csv_file_name, delete_prompt=True): | |
"""Display a download link to load a data frame as csv from within a Jupyter notebook""" | |
df.to_csv(csv_file_name, index=False) | |
from IPython.display import FileLink | |
display(FileLink(csv_file_name)) | |
if delete_prompt: | |
a = input('Press enter to delete the file after you have downloaded it.') | |
import os | |
os.remove(csv_file_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment