When I run this Code, load_data() will not return any of the data frames as pd.DataFrames. What am I doing wrong here? Thank you in advance for all your help!
def load_data():
# Competency: reading files in Pandas, df manipulation, regex
scim_en = pd.read_excel('assets/scimagojr-3.xlsx')
energy = pd.read_excel('assets/Energy Indicators.xls',na_values=["..."],header = None,skiprows=18,skipfooter= 38,usecols=[2,3,4,5],names=['Country', 'Energy Supply', 'Energy Supply per Capita', '% Renewable'])
energy['Energy Supply'] = energy['Energy Supply']*1000000
energy = energy.replace("Republic of Korea", "South Korea")
energy = energy.replace("United States of America20", "United States")
energy = energy.replace("United Kingdom of Great Britain and Northern Ireland19", "United Kingdom")
energy = energy.replace("China, Hong Kong Special Administrative Region3", "Hong Kong")
energy = energy.replace("China, Macao Special Administrative Region4", "Macao")
energy["Country"] = energy["Country"].str.extract('(^[a-zA-Zs]+)', expand=False).str.strip()
gdp = pd.read_csv('assets/world_bank.csv', skiprows = 4)
gdp = gdp.rename(columns = {'Country Name':'Country'})
gdp = gdp.replace("Korea, Rep.", "South Korea")
gdp = gdp.replace("Iran, Islamic Rep.", "Iran")
gdp = gdp.replace("Hong Kong SAR, China", "Hong Kong")
scim_en.set_index('Country')
energy.set_index('Country')
gdp.set_index('Country')
return energy, gdp, scim_en
question from:
https://stackoverflow.com/questions/65888678/why-isnt-this-function-not-returning-f-pd-dataframes-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…