返回一个合并的DataFrame,其中包含国家/地区名称,区域和CO2排放量, 给定年份。
"ConversationStateTime": "XXXXXXXXX"
Parameters
----------
year : int
The year of interest
Returns
-------
a DataFrame
A pandas DataFrame with three columns titled
'Country', 'Region', and 'CO2 emissions'.
def mergeByYear(year):
yearString = str(year)
result = pd.merge(country1, emission, on = 'Country Name')
return
答案 0 :(得分:0)
假设您问题中的代码有效,则只需调整返回的内容即可:
def mergeByYear(year):
yearString = str(year)
result = pd.merge(country1, emission, on = 'Country Name')
return result.loc[result['year'] == year]