Dataframe1: energy supply and renewable electricity production from the United Nations for the year 2013 导入"Energy Indicators.xls"去除不需要的数据,修改column名,更改列数据修改index以及更改index名
Dataframe2:GDP from 1960 to 2015 from World Bank 导入"world_bank.csv"去除不需要数据,变更index进行个别修改
Dataframe3:Sciamgo Journal and Country Rank data for Energy Engineering and Power Technology 导入"scimagojr-3.xlsx" 最后返回只有[‘Rank’, ‘Documents’, ‘Citable documents’, ‘Citations’, ‘Self-citations’, ‘Citations per document’, ‘H index’, ‘Energy Supply’, ‘Energy Supply per Capita’, ‘% Renewable’, ‘2006’, ‘2007’, ‘2008’, ‘2009’, ‘2010’, ‘2011’, ‘2012’, ‘2013’, ‘2014’, ‘2015’]这些column的Top15数据框
import pandas as pd
import numpy as np
### energy
energy = pd.read_excel('Energy Indicators.xls',skiprows=17,skip_footer =38) \
.rename(columns={
'Unnamed: 2':'Country','Petajoules':'Energy Supply','Gigajoules':'Energy Supply per Capita','%':'% Renewable'})\
[['Country','Energy Supply','Energy Supply per Capita','% Renewable']] \
.set_index('Country')# 将缺失数据'...',填充为np.nan
index = energy[energy['Energy Supply']=='...'].index
energy.loc[index,'Energy Supply']= np.nan
energy.loc[index,'Energy Supply per Capita']= np.nan
energy['Energy Supply']*=1000000
energy.astype('float64')# 修改index
energy.index = energy.index.str.split('\s\(').str[0]
energy.index = energy.index.str.split('\d').str[0]
energy.rename(index={
'Republic of Korea':'South Korea',
任务一:将三个Dataframe进行合并Dataframe1: energy supply and renewable electricity production from the United Nations for the year 2013 导入”Energy Indicators.xls”去除不需要的数据,修改column名,更改列数据修改index以及更改index名Data...