Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Tracking petrol and diesel prices Petrol and diesel prices are a source of great concern for many working individuals. The fluctuation in prices often comes
Tracking petrol and diesel prices
Petrol and diesel prices are a source of great concern for many working individuals. The fluctuation in prices often comes with massive implications in the budgets of everyday South Africans. As a Python developer, you decide to write a program to help keep track of the changes in prices, as well as the changes in the difference between the price of Petrol and Diesel.
Source: Kishinkwa
Write a Python script to assist in analysing the data in the petrolprices.csv file provided. Your program should do the following:
a Load the csv file into a dataframe and display the dataframe.
Marks
b Alter the dataframe by setting the Year and Month columns as indices.
Marks
c Add a new column to the dataframe called Price Difference and populate the column with the difference in prices between Diesel and Petrol for each row.
Marks
d Create two new dataframes from your existing dataframe containing only and data respectively.
Marks
e Plot a chart that shows Petrol and Diesel prices for and for The plots must be separate.
Marks
f Plot a line graph that shows the change in both Petrol and Diesel prices from January to December
Marks
g Plot a chart that shows the Price Difference between Diesel and Petrol.
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