0% found this document useful (0 votes)
13 views4 pages

ML Lab 1 Graphs

The document contains code to analyze supermarket sales data using Python libraries like Pandas and Seaborn. It includes code to generate various plots like bar charts and scatter plots to visualize trends in the data like total sales by product line, correlation between price and ratings, and sales over time. The code also contains warnings about deprecated parameters.

Uploaded by

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

ML Lab 1 Graphs

The document contains code to analyze supermarket sales data using Python libraries like Pandas and Seaborn. It includes code to generate various plots like bar charts and scatter plots to visualize trends in the data like total sales by product line, correlation between price and ratings, and sales over time. The code also contains warnings about deprecated parameters.

Uploaded by

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

1/11/24, 10:06 PM Untitled10.

ipynb - Colaboratory

import pandas as pd
df = pd.read_csv("supermarketsales.csv")

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Q1 Bar chart is used here


plt.figure(figsize=(12, 6))
sns.barplot(x='Product line', y='Total amount', data=df, estimator=sum, ci=None)
plt.title('Total Sales by Product Line')
plt.xlabel('Product Line')
plt.ylabel('Total Sales')
plt.show()

<ipython-input-36-69773e348612>:3: FutureWarning:

The `ci` parameter is deprecated. Use `errorbar=None` for the same effect.

sns.barplot(x='Product line', y='Total amount', data=df, estimator=sum, ci=None)

# Q2 Scatter plot is used here


plt.figure(figsize=(10, 6))
sns.scatterplot(x='Unit price', y='Rating', data=df)
plt.title('Correlation between Product Price and Customer Ratings')
plt.xlabel('Unit Price')
plt.ylabel('Customer Rating')
plt.show()

https://colab.research.google.com/drive/1wPr-x9-kma0doO2UknDmqGOj9sQ-15ZM#scrollTo=QZhBQoouW_FL&printMode=true 1/4
1/11/24, 10:06 PM Untitled10.ipynb - Colaboratory

# Q3 Bar chart is used here


plt.figure(figsize=(10, 5))
sns.barplot(x='Branch', y='Total amount', data=df, estimator=sum, ci=None)
plt.title('Total Sales by Supplier')
plt.xlabel('Supplier Name')
plt.ylabel('Total Sales')
plt.show()

https://colab.research.google.com/drive/1wPr-x9-kma0doO2UknDmqGOj9sQ-15ZM#scrollTo=QZhBQoouW_FL&printMode=true 2/4
1/11/24, 10:06 PM Untitled10.ipynb - Colaboratory

<ipython-input-38-eea42ebf4fd6>:3: FutureWarning:

The `ci` parameter is deprecated. Use `errorbar=None` for the same effect.

sns.barplot(x='Branch', y='Total amount', data=df, estimator=sum, ci=None)

# Q4
plt.figure(figsize=(12, 6))
sns.barplot(x='Product line', y='Total amount', data=df, estimator=sum, ci=None)
plt.title('Total Sales by Product Line')
plt.xlabel('Product Line')
plt.ylabel('Total Sales')
plt.show()

https://colab.research.google.com/drive/1wPr-x9-kma0doO2UknDmqGOj9sQ-15ZM#scrollTo=QZhBQoouW_FL&printMode=true 3/4
1/11/24, 10:06 PM Untitled10.ipynb - Colaboratory

<ipython-input-39-413a269182fc>:3: FutureWarning:

The `ci` parameter is deprecated. Use `errorbar=None` for the same effect.
# Q5
sns.barplot(x='Product
df['Date'] line', y='Total
= pd.to_datetime(df['Date'], amount', data=df, estimator=sum, ci=None)
format='%B')
plt.figure(figsize=(12, 6))
sns.lineplot(x='Date', y='Total amount', data=df, estimator=sum, ci=None)
plt.title('Sales Performance Over Time')
plt.xlabel('Month')
plt.ylabel('Total Sales')
plt.show()

output <ipython-input-40-e6644d0da547>:4: FutureWarning:

The `ci` parameter is deprecated. Use `errorbar=None` for the same effect.

sns.lineplot(x='Date', y='Total amount', data=df, estimator=sum, ci=None)

https://colab.research.google.com/drive/1wPr-x9-kma0doO2UknDmqGOj9sQ-15ZM#scrollTo=QZhBQoouW_FL&printMode=true 4/4

You might also like