Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

USING PYTHON Using this data, write a python code to answer the following questions: 1.) Clean the data in the DataFrame Energy. The detailed steps

USING PYTHON

image text in transcribed

Using this data, write a python code to answer the following questions:

1.) Clean the data in the DataFrame Energy. The detailed steps are as follows. Steps: 1. For all the countries which have missing data (e.g., data with '...'), represent them as np.NaN values. 2. "Energy Supply" is in petajoules but "Energy Supply per capita" is in gigajoules. Please convert the "Energy Supply" to gigajoules (there are 1,000,000 gigajoules in a petajoule). 3. Rename the following list of countries: "Republic of Korea": "South Korea", "United States of America": "United States", "United Kingdom of Great Britain and Northern Ireland": "United Kingdom", "China, Hong Kong Special Administrative Region": "Hong Kong"

2.) Process the DataFrame gdp The detailed steps are as follows. Steps: 1. Rename the following list of countries in "Country Name": "Korea, Rep.": "South Korea", "Iran, Islamic Rep.": "Iran", "Hong Kong SAR, China": "Hong Kong" 2. Copy the column "Country Name" and the last 5 years (2013-2017) of GDP data to the DataFrame **GDP**. 3. Change the column name "Country Name" to "Country".

3.) Join the dataset Energy and GDP. Create a new DataFrame energyGDP which select the top 10 countries in energy supply of the joined dataset. Set the column "Country Name" to be the index of "energyGDP". Steps: 1. Merge energy and GDP with the key "Country Name". 2. Sort the merged dataset by the values in the column 'Country Name' in descending order. 3. Select the first 10 rows of the sorted dataset and assign it to energyGDP. 4. Set the column "Country Name" to be the index of "energyGDP".

4.) Create two new columns in energeGDP. Steps: 1. Create a new column called "Mean GDP" which records the average GDP in the last 5 years (2013-2017). 2. Create a new column called "E2GRatio" which records the ratio of "Energy Supply" to "Mean GDP".

5.) 1. Find the country with the highest "Renewable Percentage". 2. Find the country with the least ratio of "Energy Supply" to "Mean GDP".

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

8. Design office space to facilitate interaction between employees.

Answered: 1 week ago