KEMBAR78
DSA Lab Exp1 | PDF | Data | Information Technology
0% found this document useful (0 votes)
4 views3 pages

DSA Lab Exp1

Uploaded by

kashyapkumar2007
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)
4 views3 pages

DSA Lab Exp1

Uploaded by

kashyapkumar2007
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/ 3

Here's a simple and complete example of a Data Science and Business Intelligence Lab

Experiment using Python (Jupyter Notebook or Google Colab) with full code, dataset, and
step-by-step explanations.

🧪 Lab Experiment: Sales Data Analysis using Python

🎯 Objective

Analyze a small sales dataset to uncover insights such as total revenue, best-performing
products, and sales by region.

🧰 Tools Used

 Python 3
 Jupyter Notebook or Google Colab
 Libraries: pandas, matplotlib, seaborn

📦 Step 1: Sample Dataset

Let’s use a simple in-memory dataset (no file needed).

import pandas as pd

# Create a simple dataset


data = {
'Date': ['2025-07-01', '2025-07-02', '2025-07-02', '2025-07-03', '2025-07-
03', '2025-07-04'],
'Product': ['Laptop', 'Tablet', 'Laptop', 'Monitor', 'Tablet', 'Monitor'],
'Region': ['North', 'South', 'East', 'North', 'East', 'South'],
'Units_Sold': [5, 3, 7, 2, 4, 3],
'Unit_Price': [800, 300, 800, 200, 300, 200]
}

# Convert to DataFrame
df = pd.DataFrame(data)

# Compute total sales


df['Total_Sales'] = df['Units_Sold'] * df['Unit_Price']

# Display data
df
🔍 Step 2: Data Exploration & Summary Stats
# Basic info
print(df.info())
print("\nSummary statistics:")
print(df.describe())

# Total revenue
total_revenue = df['Total_Sales'].sum()
print(f"\n💰 Total Revenue: ${total_revenue}")

📊 Step 3: Sales by Product and Region


# Sales by Product
sales_by_product = df.groupby('Product')
['Total_Sales'].sum().sort_values(ascending=False)
print("\n📦 Sales by Product:\n", sales_by_product)

# Sales by Region
sales_by_region = df.groupby('Region')['Total_Sales'].sum()
print("\n🌍 Sales by Region:\n", sales_by_region)

📈 Step 4: Visualization
import matplotlib.pyplot as plt
import seaborn as sns

# Bar chart for Product Sales


plt.figure(figsize=(8, 4))
sns.barplot(x=sales_by_product.index, y=sales_by_product.values,
palette="viridis")
plt.title('Sales by Product')
plt.ylabel('Total Sales ($)')
plt.xlabel('Product')
plt.tight_layout()
plt.show()

# Pie chart for Region Sales


plt.figure(figsize=(6, 6))
plt.pie(sales_by_region.values, labels=sales_by_region.index, autopct='%1.1f%
%', startangle=140)
plt.title('Sales Distribution by Region')
plt.show()

📌 Step 5: Insights & Business Intelligence


print("✅ Business Insights:")
print("- Laptop has the highest revenue.")
print("- The North region contributes significantly to sales.")
print("- Consider focusing promotions on Tablets in the South region to boost
sales.")

✅ Final Output
You now have:

 A cleaned and structured dataset


 Summary statistics
 Grouped sales data
 Visualizations (bar and pie charts)
 Business insights derived from data

💻 How to Run

 Copy and paste this into a Jupyter Notebook or Google Colab.


 Make sure pandas, matplotlib, and seaborn are installed (pip install pandas
matplotlib seaborn if needed).

You might also like