Write a function bathing_soap_sales (fp, output_name) that takes the input fp as the name of a csv file containing sales

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a function bathing_soap_sales (fp, output_name) that takes the input fp as the name of a csv file containing sales

Post by answerhappygod »

Write A Function Bathing Soap Sales Fp Output Name That Takes The Input Fp As The Name Of A Csv File Containing Sales 1
Write A Function Bathing Soap Sales Fp Output Name That Takes The Input Fp As The Name Of A Csv File Containing Sales 1 (55.09 KiB) Viewed 23 times
CAN SOMEONE PLEASE FIX MY CODE. ANSWERS PROVIDED FROM THIS
WEBSITE KEEP ON BEING WRONG.
I HAVE PROVIDED SCREENSHOTS OF THE QUESTION, EXAMPLE OF GRAPH,
TESTS YOU CAN RUN ON CODE, MY INCORRECT CODE THAT NEEDS
FIXING/REPLACING, AND THE ERRORS MY CODE PRODUCED.
Write a function bathing_soap_sales (fp, output_name) that takes the input fp as the name of a csv file containing sales data and output_name as the name of the produced plot.png. It then reads the contents as a Pandas dataframe, then plots a bar graph of bathing soap on the y-axis against month_number on the x-axis. You must use the Pandas dataframe plot method to create your bargraph. The graph itself must by formatted in this way: figure size is set to (10, 8) • x-axis tick labels are aligned vertically, not horizontally • legend is removed • a grid is applied over the plot area with a line width of 1 and a line style of '--' • x-axis label is 'Month' y-axis label is 'Sales Units' • plot title is 'Bathing Soap Sales Data' Finally, save the graph as output_name with a default value "output.png". The expected output when using plt.show() (for testing purposes) is seen below:
Sales Units 14000 12000 10000 8000 6000 4000 2000 0 1 2 3 4 Bathing Soap Sales Data 6 8 7 Month 5 9 10 11 12
import pandas as pd import matplotlib.pyplot as plt def bathing_soap_sales (fp, output_name = "output.png"): """""produces graph"!!!!** data=pd. read_csv (fp) df=pd.DataFrame (data) x_data= list(df.iloc[:, 0]) y_data = list(df.iloc[:, 1]) plt. figure(figsize=(10,8)) plt.xticks (rotation=90) plt.ylim( [0, 14000]) plt.xlabel('Month') plt.ylabel('Sales Unit') plt.title('Bathing Soap Sales Data') plt.bar(x_data, y_data) plt.bar(fp, output_name, label='Month') plt.grid (True, linewidth = "1", linestyle="--") plt.savefig (output_name)
Got Your graph is different to the expected output, difference: 0.1609 * Your graph is different to the expected output, difference: 0.1609 * Your graph is different to the expected output, difference: 0.1609 X
Test bathing_soap_sales('company_sales_data.csv') ans ('company_sales_data.csv') val = main("output.png", "answer.png") if val <= 0.05: print("Pass!") else: print("Your graph is different to the expected output, difference: { bathing_soap_sales('company_sales_data.csv') ans ('company_sales_data.csv') val = main("output.png", "answer.png") if val <= 0.1: print("Nearly!") else: print("Your graph is different to the expected output, difference: { bathing_soap_sales('company_sales_data.csv') ans ('company_sales_data.csv') val = main("output.png", "answer.png") if val <= 0.15: print("Partial") else: print("Your graph is different to the expected output, difference:
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply