Answered step by step
Verified Expert Solution
Link Copied!

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.2024).
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.
(2 Marks)
b. Alter the dataframe by setting the Year and Month columns as indices.
(3 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.
(5 Marks)
d. Create two new dataframes (from your existing dataframe) containing only 2023 and 2024 data respectively.
(6 Marks)
e. Plot a chart that shows Petrol and Diesel prices for 2023 and for 2024. The plots must be separate.
(3 Marks)
f. Plot a line graph that shows the change in both Petrol and Diesel prices from January 2023 to December 2024.
(3 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

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions