Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
231 views

Assignment: Master in Business Administration

This document contains 10 assignments involving analyzing sales data from a company and visualizing it using various Python plotting techniques like line plots, scatter plots, bar plots, histograms, pie charts, subplots, and stack plots. The assignments involve reading in CSV data, extracting relevant columns of data, and using Matplotlib to plot the monthly sales and profit data of different products over time to identify trends, compare products, and understand the overall sales performance.

Uploaded by

kisan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
231 views

Assignment: Master in Business Administration

This document contains 10 assignments involving analyzing sales data from a company and visualizing it using various Python plotting techniques like line plots, scatter plots, bar plots, histograms, pie charts, subplots, and stack plots. The assignments involve reading in CSV data, extracting relevant columns of data, and using Matplotlib to plot the monthly sales and profit data of different products over time to identify trends, compare products, and understand the overall sales performance.

Uploaded by

kisan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

ASSIGNMENT

Submitted by
SOVAN DAS
REGD: 190402120003
In partial fulfilment for the award of the degree
Of
MASTER IN BUSINESS ADMINISTRATION
of

Data Analytics

SCHOOL of

MANAGEMENT

CENTURION UNIVERSITY OF TECHNOLOGY&MANAGEMENT,


BHUBANESWAR, ODISHA

1: Read Total profit of all months and show it using a line plot
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/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 dollar')

plt.xticks(monthList)

plt.title('Company profit per month')

plt.yticks([100000, 200000, 300000, 400000, 500000])

plt.show()
2: Get Total profit of all months and show line plot with the
following Style properties
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

profitList = df ['total_profit'].tolist()

monthList = df ['month_number'].tolist()

plt.plot(monthList, profitList, label = 'Profit data of last year',

color='r', marker='o', markerfacecolor='k',

linestyle='--', linewidth=3)

plt.xlabel('Month Number')

plt.ylabel('Profit in dollar')

plt.legend(loc='lower right')

plt.title('Company Sales data of last year')

plt.xticks(monthList)

plt.yticks([100000, 200000, 300000, 400000, 500000])

plt.show()
3: Read all product sales data and show it  using a multiline plot
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

faceCremSalesData = df ['facecream'].tolist()

faceWashSalesData = df ['facewash'].tolist()

toothPasteSalesData = df ['toothpaste'].tolist()

bathingsoapSalesData = df ['bathingsoap'].tolist()

shampooSalesData = df ['shampoo'].tolist()

moisturizerSalesData = df ['moisturizer'].tolist()

plt.plot(monthList, faceCremSalesData, label = 'Face cream Sales Data', marker='o', linewidth=3)

plt.plot(monthList, faceWashSalesData, label = 'Face Wash Sales Data', marker='o', linewidth=3)

plt.plot(monthList, toothPasteSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)

plt.plot(monthList, bathingsoapSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)

plt.plot(monthList, shampooSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)

plt.plot(monthList, moisturizerSalesData, label = 'ToothPaste Sales Data', marker='o', linewidth=3)

plt.xlabel('Month Number')

plt.ylabel('Sales units in number')

plt.legend(loc='upper left')

plt.xticks(monthList)

plt.yticks([1000, 2000, 4000, 6000, 8000, 10000, 12000, 15000, 18000])

plt.title('Sales data')

plt.show()
4: Read toothpaste sales data of each month and show it using a
scatter plot
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

toothPasteSalesData = df ['toothpaste'].tolist()

plt.scatter(monthList, toothPasteSalesData, label = 'Tooth paste Sales data')

plt.xlabel('Month Number')

plt.ylabel('Number of units Sold')

plt.legend(loc='upper left')

plt.title(' Tooth paste Sales data')

plt.xticks(monthList)

plt.grid(True, linewidth= 1, linestyle="--")

plt.show()
5: Read face cream and facewash product sales data and show it
using the bar chart
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

faceCremSalesData = df ['facecream'].tolist()

faceWashSalesData = df ['facewash'].tolist()

plt.bar([a-0.25 for a in monthList], faceCremSalesData, width= 0.25, label = 'Face Cream sales data',
align='edge')

plt.bar([a+0.25 for a in monthList], faceWashSalesData, width= -0.25, label = 'Face Wash sales data',
align='edge')

plt.xlabel('Month Number')

plt.ylabel('Sales units in number')

plt.legend(loc='upper left')

plt.title(' Sales data')

plt.xticks(monthList)

plt.grid(True, linewidth= 1, linestyle="--")

plt.title('Facewash and facecream sales data')

plt.show()
6: Read sales data of bathing soap of all months and show it
using a bar chart. Save this plot to your hard disk
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

bathingsoapSalesData = df ['bathingsoap'].tolist()

plt.bar(monthList, bathingsoapSalesData)

plt.xlabel('Month Number')

plt.ylabel('Sales units in number')

plt.title(' Sales data')

plt.xticks(monthList)

plt.grid(True, linewidth= 1, linestyle="--")

plt.title('bathingsoap sales data')

plt.show()
7: Read the total profit of each month and show it using the
histogram to see most common profit ranges
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

profitList = df ['total_profit'].tolist()

labels = ['low', 'average', 'Good', 'Best']

profit_range = [150000, 175000, 200000, 225000, 250000, 300000, 350000]

plt.hist(profitList, profit_range, label = 'Profit data')

plt.xlabel('profit range in dollar')

plt.ylabel('Actual Profit in dollar')

plt.legend(loc='upper left')

plt.xticks(profit_range)

plt.title('Profit data')

plt.show()
8: Calculate total sale data for last year for each product and
show it using a Pie chart
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

labels = ['FaceCream', 'FaseWash', 'ToothPaste', 'Bathing soap', 'Shampoo', 'Moisturizer']

salesData = [df ['facecream'].sum(), df ['facewash'].sum(), df ['toothpaste'].sum(),

df ['bathingsoap'].sum(), df ['shampoo'].sum(), df ['moisturizer'].sum()]

plt.axis("equal")

plt.pie(salesData, labels=labels, autopct='%1.1f%%')

plt.legend(loc='lower right')

plt.title('Sales data')

plt.show()
9: Read Bathing soap facewash of all months and display it using
the Subplot
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

bathingsoap = df ['bathingsoap'].tolist()

faceWashSalesData = df ['facewash'].tolist()

f, axarr = plt.subplots(2, sharex=True)

axarr[0].plot(monthList, bathingsoap, label = 'Bathingsoap Sales Data', color='k', marker='o',


linewidth=3)

axarr[0].set_title('Sales data of a Bathingsoap')

axarr[1].plot(monthList, faceWashSalesData, label = 'Face Wash Sales Data', color='r', marker='o',


linewidth=3)

axarr[1].set_title('Sales data of a facewash')


plt.xticks(monthList)

plt.xlabel('Month Number')

plt.ylabel('Sales units in number')

plt.show()

10: Read all product sales data and show it using the stack plot
import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("C:/Users/RS/Desktop/paython/company_sales_data.csv")

monthList = df ['month_number'].tolist()

faceCremSalesData = df ['facecream'].tolist()

faceWashSalesData = df ['facewash'].tolist()

toothPasteSalesData = df ['toothpaste'].tolist()

bathingsoapSalesData = df ['bathingsoap'].tolist()

shampooSalesData = df ['shampoo'].tolist()

moisturizerSalesData = df ['moisturizer'].tolist()

plt.plot([],[],color='m', label='face Cream', linewidth=5)

plt.plot([],[],color='c', label='Face wash', linewidth=5)


plt.plot([],[],color='r', label='Tooth paste', linewidth=5)

plt.plot([],[],color='k', label='Bathing soap', linewidth=5)

plt.plot([],[],color='g', label='Shampoo', linewidth=5)

plt.plot([],[],color='y', label='Moisturizer', linewidth=5)

plt.stackplot(monthList, faceCremSalesData, faceWashSalesData, toothPasteSalesData,

bathingsoapSalesData, shampooSalesData, moisturizerSalesData,

colors=['m','c','r','k','g','y'])

plt.xlabel('Month Number')

plt.ylabel('Sales unints in Number')

plt.title('Alll product sales data using stack plot')

plt.legend(loc='upper left')

plt.show()

You might also like