0% found this document useful (0 votes)
39 views2 pages

Aiml Ex2

This document discusses using Python to analyze sales and profit data from a CSV file. It generates 4 plots - a count plot to show categorical data frequencies, a pie chart showing monthly sales amounts, a scatter plot of sales vs profit amounts, and a box plot of sales data. It loads the CSV, prints the data, then uses Seaborn and Matplotlib to create the various visualizations for analyzing the numerical and categorical data.

Uploaded by

Tasmiya Dz
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)
39 views2 pages

Aiml Ex2

This document discusses using Python to analyze sales and profit data from a CSV file. It generates 4 plots - a count plot to show categorical data frequencies, a pie chart showing monthly sales amounts, a scatter plot of sales vs profit amounts, and a box plot of sales data. It loads the CSV, prints the data, then uses Seaborn and Matplotlib to create the various visualizations for analyzing the numerical and categorical data.

Uploaded by

Tasmiya Dz
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/ 2

Practical No.

Program:-
import numpy as np  #required for mathematical calculation
import pandas as pd   #required for vector and array
import matplotlib.pyplot as plt
import seaborn as sns
from seaborn import load_dataset
from google.colab import files
uploaded=files.upload()
temp = pd.read_csv("SalesNProfit.csv")
print(temp)
Categorical Data
1) CountPlot
sns.countplot( data = temp)
plt.xlabel("X-axis")

plt.show()

2) Pie Chart
a=temp.loc[:,"Sales"]

month=['1','2','3','4','5','6','7','8','9']
# Creating plot
fig = plt.figure(figsize =(10, 10))
plt.pie(a[1:10],labels = month)
 # show plot
plt.show()

Numerical Data
1) Scatter Plot
x = list(temp['Sales'])    #temp is the data name
y = list(temp['Profit'])   #temp is the data name
plt.scatter(x,y)         
plt.show()

2) Box Plot
plt.boxplot(temp[1:23])
# show plot

1
Practical No. 2

plt.show()
3) Line plot
a=temp.loc[:,"Sales"]
x = list(a[:25])    
y = range(25)
plt.xlabel("X-axis")
plt.ylabel("y-axis")
plt.legend('temp')
plt.title('The sales for first 25 years')
plt.plot(y,x)
plt.show()

Output:-

Figure 1 count plot Figure 2 Pie Chart

Figure 4 Line Chart


Figure 3 Scatter Plot

Conclusion:-

 In this practical different types of plot are used to analyze the data.

You might also like