0

I am completely new to JupyterLab and python in general so I am looking for some help today. Specifically, I am interested in getting data from JuypterLab into Excel. The data I have in JL are tables that I have pulled from the internet, using the pandas function as shown in the link below. My next step that I am having trouble with is how to pull those data tables from JL to Excel. Is there a 'Get Data' function that is best for this or would it be easier using python to accomplish this task? Ideally, I want to be able to do this for a large set of data/tables that I scrape from the internet.

I'm starting using the answer to a question I asked previously: Web scraping multiple tables from a single webpage

import pandas as pd
df =pd.read_html('https://www.basketball-reference.com/international/players/roko-prkacin-1.html')[0:4]
print(df)
Michael Delgado
  • 13,789
  • 3
  • 29
  • 54
TNieland
  • 27
  • 6

1 Answers1

2

If you have a pandas dataframe getting it into excel-format is very easy:

df.to_excel("filename.xlsx")

see also the documentation: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_excel.html

To get meaningfull dataframes from html is something different.

samoncode
  • 466
  • 2
  • 7
  • 23
  • Thanks! How much more of a project is it to pull multiple pandas dataframes into a single (or several) Excel workbook? – TNieland Jul 07 '22 at 19:57
  • By providing the parameter "sheet_name" you can write the dataframes to different excel sheets: df.to_excel("filename.xlsx", sheet_name="sheet1") than write the next dataframe to another sheet. df2.to_excel("filename.xlsx", sheet_name="sheet2" – samoncode Jul 08 '22 at 07:51