I am trying to fix the code I've posted below. It works properly and my CSV file exports as intended, but I get a warning in my terminal: "The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead."
I reviewed the examples in the documentation and another thread on Stack Overflow, but I am having trouble getting the concat to actually work. It won't accept a data frame object so I have tried to convert to a list but I'm having a difficult time getting things to work like they do now. Could anyone help me replace this bit of code with the more future proof concat method?
import pandas as pd
result = pd.DataFrame()
for i in range (2013,2023):
year = str(i)
url = 'https://www.hockey-reference.com/leagues/NHL_'+year+'_skaters.html'
df = pd.read_html(url,header=1)[0]
df['year'] = year
result = result.append(df, sort=False)
result = result[~result['Age'].str.contains("Age")]
result = result.reset_index(drop=True)
result.to_csv('hdb_data.csv',index=False)