KnowledgeBoat Logo
|

Informatics Practices

Hindustan Departmental Stores sell items of daily use such as shampoo, soap and much more. They record the entire sale and purchase of goods month-wise so as to get a proper analysis of profit or loss in their business transactions.

Following is the csv file containing the "Company Sales Data".

Hindustan Departmental Stores sell items of daily use such as shampoo, soap and much more. They record the entire sale and purchase of goods month-wise so as to get a proper analysis of profit or loss in their business transactions. Data Visualization using Matplotlib, Informatics Practices Preeti Arora Solutions CBSE Class 12

Read the total profit of all months and show it using a line plot. Total profit data has been provided for each month. Generated line plot must include the following properties:

  • X label name = Month Number
  • Y label name = Total profit

PyPlot

3 Likes

Answer

import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("C:\\company_sales_data.csv")
profitList = df['total_profit'].tolist()
monthList = df['month_number'].tolist()
plt.plot(monthList, profitList, label = 'Month-wise Profit data of last year')
plt.xlabel('Month number')
plt.ylabel("Profit in dollars")
plt.xticks(monthList)
plt.title('Company profit per month')
plt.yticks([100000, 200000, 300000, 400000, 500000])
plt.show()
Output
Hindustan Departmental Stores sell items of daily use such as shampoo, soap and much more. They record the entire sale and purchase of goods month-wise so as to get a proper analysis of profit or loss in their business transactions. Data Visualization using Matplotlib, Informatics Practices Preeti Arora Solutions CBSE Class 12

Answered By

3 Likes


Related Questions