0% found this document useful (0 votes)
2 views7 pages

Data Visualization LabTask

The document outlines a series of data visualization lab tasks focusing on structured, unstructured, and temporal data. It includes specific coding examples for visualizing sales data, student marks, word frequencies, sentiment analysis, and stock trends using various chart types. Additionally, it presents a case study on e-commerce sales visualization, detailing insights on top products, revenue trends, and sales distribution by category and city.

Uploaded by

mundwariyanaresh
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)
2 views7 pages

Data Visualization LabTask

The document outlines a series of data visualization lab tasks focusing on structured, unstructured, and temporal data. It includes specific coding examples for visualizing sales data, student marks, word frequencies, sentiment analysis, and stock trends using various chart types. Additionally, it presents a case study on e-commerce sales visualization, detailing insights on top products, revenue trends, and sales distribution by category and city.

Uploaded by

mundwariyanaresh
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

Data Visualization lab tasks covering:

• Structured Data
• Unstructured Data
• Temporal (Time-Series) Data

PART 1: Structured Data Visualization

1. Sales by Category (Bar Chart)


Problem

Visualize total sales per product category.

Code
import pandas as pd
import [Link] as plt

data = [Link]({
'Category': ['Electronics', 'Clothing', 'Food'],
'Sales': [50000, 30000, 20000]
})

[Link](data['Category'], data['Sales'])
[Link]("Category")
[Link]("Sales")
[Link]("Sales by Category")
[Link]()

2. Student Marks Distribution (Histogram)


Problem

Show distribution of marks.

import [Link] as plt

marks = [45, 67, 89, 90, 56, 72, 88, 95]

[Link](marks)
[Link]("Marks Distribution")
[Link]("Marks")
[Link]("Frequency")
[Link]()
3. Correlation Heatmap
Problem

Show relationship between features.

import pandas as pd
import [Link] as plt

data = [Link]({
'Math': [80, 70, 90],
'Science': [85, 75, 95],
'English': [78, 72, 88]
})

corr = [Link]()

[Link](corr)
[Link]()
[Link](range(len(corr)), [Link])
[Link](range(len(corr)), [Link])
[Link]("Correlation Heatmap")
[Link]()

4. Pie Chart (Market Share)


Problem

Visualize company market share.

labels = ['A', 'B', 'C']


sizes = [40, 35, 25]

[Link](sizes, labels=labels, autopct='%1.1f%%')


[Link]("Market Share")
[Link]()

PART 2: Unstructured Data Visualization

5. Word Frequency Bar Chart


Problem

Find most common words from text.

from collections import Counter


import [Link] as plt
text = "data science is fun data is powerful"
words = [Link]()

freq = Counter(words)
[Link]([Link](), [Link]())
[Link]("Word Frequency")
[Link]()

6. Word Cloud
Problem

Generate word cloud from text.

from wordcloud import WordCloud


import [Link] as plt

text = "data science machine learning python data"

wc = WordCloud().generate(text)

[Link](wc)
[Link]("off")
[Link]()

7. Sentiment Count Visualization


Problem

Plot count of positive/negative reviews.

import [Link] as plt

sentiments = ['Positive', 'Negative', 'Neutral']


counts = [50, 30, 20]

[Link](sentiments, counts)
[Link]("Sentiment Analysis")
[Link]()

PART 3: Temporal (Time-Series) Data


8. Stock Price Trend (Line Chart)
Problem

Plot stock prices over time.

import pandas as pd
import [Link] as plt

data = [Link]({
'Date': ['Day1', 'Day2', 'Day3'],
'Price': [100, 105, 102]
})

[Link](data['Date'], data['Price'])
[Link]("Stock Price Trend")
[Link]("Date")
[Link]("Price")
[Link]()

9. Moving Average
Problem

Smooth time-series data.

import pandas as pd
import [Link] as plt

data = [Link]([10, 20, 30, 40, 50])

rolling = [Link](2).mean()

[Link](data, label="Original")
[Link](rolling, label="Moving Avg")
[Link]()
[Link]()

10. Sales Over Time with Trend


Problem

Show trend in sales.

sales = [100, 120, 130, 150, 170]

[Link](sales)
[Link]("Sales Trend")
[Link]("Time")
[Link]("Sales")
[Link]()

Sample case study : E-commerce Sales Visualization Lab Task

Objective

Analyze and visualize e-commerce sales data to identify:

• Top products
• Revenue trends
• Category performance
• Monthly sales patterns

Sample Dataset (CSV)


OrderID,Date,Product,Category,Price,Quantity,City
101,2024-01-05,Laptop,Electronics,50000,1,Delhi
102,2024-01-06,Shirt,Clothing,1500,2,Mumbai
103,2024-01-07,Mobile,Electronics,20000,1,Bangalore
104,2024-02-01,Shoes,Footwear,3000,1,Delhi
105,2024-02-10,Headphones,Electronics,2000,3,Mumbai
106,2024-03-12,T-shirt,Clothing,800,4,Jaipur
107,2024-03-15,Laptop,Electronics,55000,1,Delhi
108,2024-04-01,Shoes,Footwear,3200,2,Mumbai

Step 1: Load & Prepare Data


import pandas as pd
import [Link] as plt

df = pd.read_csv("[Link]")

# Convert date column


df['Date'] = pd.to_datetime(df['Date'])

# Create revenue column


df['Revenue'] = df['Price'] * df['Quantity']

print([Link]())
1. Sales by Category (Bar Chart)
Insight: Which category earns most?
category_sales = [Link]('Category')['Revenue'].sum()

[Link](category_sales.index, category_sales.values)
[Link]("Category")
[Link]("Revenue")
[Link]("Revenue by Category")
[Link]()

2. Monthly Sales Trend (Time-Series)


Insight: Growth over time
monthly_sales = [Link]('M', on='Date')['Revenue'].sum()

[Link](monthly_sales.index, monthly_sales.values)
[Link]("Monthly Sales Trend")
[Link]("Month")
[Link]("Revenue")
[Link]()

3. Top Selling Products


Insight: Best-performing products
product_sales = [Link]('Product')['Revenue'].sum()

product_sales = product_sales.sort_values(ascending=False)

[Link](product_sales.index, product_sales.values)
[Link](rotation=30)
[Link]("Top Products by Revenue")
[Link]()

4. Sales by City
Insight: Geographic performance
city_sales = [Link]('City')['Revenue'].sum()

[Link](city_sales.values, labels=city_sales.index, autopct='%1.1f%%')


[Link]("Sales Distribution by City")
[Link]()
5. Quantity Sold per Category
Insight: Demand vs revenue
qty = [Link]('Category')['Quantity'].sum()

[Link]([Link], [Link])
[Link]("Quantity Sold per Category")
[Link]()

6. Moving Average (Advanced Temporal)


Insight: Smooth trend
monthly_sales_ma = monthly_sales.rolling(2).mean()

[Link](monthly_sales, label="Original")
[Link](monthly_sales_ma, label="Moving Avg")
[Link]()
[Link]("Sales with Moving Average")
[Link]()

Key Concepts Covered


Concept Where Used

Structured Data CSV dataset

Aggregation groupby()

Time-Series resample()

Trend Analysis line chart

Comparison bar chart

Distribution pie chart

Further(can be performed)

• Add discount column and recalculate revenue


• Find top city per category
• Plot daily sales instead of monthly
• Identify least selling product
• Compare Electronics vs Clothing trend

You might also like