Home > database >  Creating and Editing a DataFrame
Creating and Editing a DataFrame

Time:06-29

I have tried many times to turn the "data" from a list to a dataFrame because its saying its not 2d, which it isn't but i don't know why its not. Its saying its a 1 by 137 by 29 and i am not sure how to fix this so that i can then edit that dataframe.

from selenium import webdriver
import time
import pandas as pd


PATH = "C:\Program Files (x86)\Chrome\chromedriver_win32\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.maximize_window()

page = driver.get("https://www.europeantour.com/dpworld-tour/abu-dhabi-hsbc-championship-2021/leaderboard?holebyhole=true&round=1")
time.sleep(3)

data = pd.read_html(driver.page_source)

driver.quit()

CodePudding user response:

The variable 'data' is a list of dataframes. Here, it's a list of just 1 dataframe. To access the dataframe, use data[0]. If you wish to store it in a new variable,

df = data[0]

Variable 'df' is the dataframe you're looking for

  • Related