Question
There is a csv file in '../data/primary-energy-consumption-by-region.csv' that has the energy consumption of different regions of the world from 1965 until 2018 Our world in
There is a csv file in '../data/primary-energy-consumption-by-region.csv' that has the energy consumption of different regions of the world from 1965 until 2018 Our world in Data. We are going to compare the energy consumption of the United States to all of Europe. Load the data into a pandas dataframe. Note: we can get certain rows of the data frame by specifying what we're looking for e.g. EUR = dataframe[dataframe['Entity']=='Europe'] will give us all the rows from Europe's energy consumption.
a. Plot the total energy consumption of the United States and Europe
b. Use a linear least-squares regression to find a function for the energy consumption as a function of year
energy consumed = ()=+f(t)=At+B
c. At what year would you change split the data and use two lines like we did in the land temperature anomoly? Split the data and perform two linear fits.
d. What is your prediction for US energy use in 2025? How about European energy use in 2025?
In Python
energy = pd.read_csv('../data/primary-energy-consumption-by-region.csv') CAN = energy[energy['Entity']=='Canada'] USA = energy[energy['Entity']=='United States'] EUR = energy[energy['Entity']=='Europe'] plt.plot(USA['Year'],USA['Primary Energy Consumption (terawatt-hours)'],'-o') plt.plot(EUR['Year'],EUR['Primary Energy Consumption (terawatt-hours)'],'-s')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started