2.to Acquire, Visualize and Analyze The Data Set
2.to Acquire, Visualize and Analyze The Data Set
Practical No. 02
Objectives:
Problem Definition:-
The data set is sales and profit data of company products for 25 years. The data is in CSV
format. The aim is to plot different types of plots to analyze the data visually.
Input data
1. Dataset given in form of .csv file (comma separated values)
Program:-
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
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:-
Conclusion:-
● In this practical different types of plot are used to analyze the data.