Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Need help using pandas to covert a url into a dataframe for college basketball data

I am trying to get barttorvik.com data into a dataframe. I can scrape with the following code, but I get an error when trying to export the dataframe into excel.

I am assuming the error has to do with the header row on the site’s table. I am unsure how to modify the imported data to make it exportable. Any help would be appreciated and thank you in advance.

import pandas as pd
url = 'https://www.barttorvik.com/#'
df = pd.read_html(url)
df.to_excel('/outputdestination', index=False)

This is the error I get after running the code

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

AttributeError: 'list' object has no attribute 'to_excel'

>Solution :

See https://pandas.pydata.org/docs/reference/api/pandas.read_html.html. It returns a list of Dataframes.

df[0].to_excel('./outputdestination', index=False)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading