Question: You are provided with a CSV file named breadprice.csv, which contains monthly average bread prices for multiple years. Your task is to create a Python

You are provided with a CSV file named breadprice.csv, which contains monthly average bread prices for multiple years. Your task is to create a Python program that will: Load the Data: Load the CSV data into a pandas DataFrame. Clean the Data: Drop the "Year" column from the DataFrame and store it in a separate variable. If any missing (NaN) values exist, replace them with the mean of the respective row. Calculate Yearly Statistics: For each year in the dataset: Calculate the average and median of the bread prices for that year. Display the Results: Print the yearly average and median prices. Plot the Results: Create a line plot showing the yearly average and median bread prices, where the x-axis represents the years and the y-axis represents the prices. You will need to generate a Python script named breadprice-ver2.py to implement the following steps: Load and clean the dataset. Calculate and display the yearly average and median bread prices. Create a plot for the average and median prices. Example of What the Output Should Look Like: Year Average Price Median Price -------------------------------------- 2000 2.75 2.70 2001 2.80 2.78 2002 2.85 2.82

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!