I am trying to figure out how to download data from jupyter lab to the local download folder. Sample Code below. For my current code, the excel gets downloaded to the folder in lab. However, since the code will be used by others, the download needs to take place on their systems(download folder). How to add this option? I have tried using the "download_path = os.path.expanduser("~") + "/Downloads/"" optio but this saves it to the static folder
import pandas as pd
import numpy as np
import xlsxwriter
def create_dataframes():
df = pd.DataFrame(np.array([["A", 2021, 200, 400],
["B", 2020, 600, 300],
["A", 2021, 500, 250],
["B", 2030, 350, 432],
["C", 2022, 250, 532],
["C", 2022, 150, 232],]),
columns=['Category', 'Year', 'Value_1', 'Value_2'])
df1 = pd.DataFrame(np.array([["D", 2021, 200, 400],
["D", 2020, 600, 300],
["B", 2021, 500, 250],
["B", 2020, 350, 432],
["C", 2022, 250, 532],
["C", 2022, 150, 232],]),
columns=['Category', 'Year', 'Value_1', 'Value_2'])
with pd.ExcelWriter('test_output.xlsx') as writer:
df.to_excel(writer, sheet_name='A')
df1.to_excel(writer, sheet_name='C')