Friday, November 14, 2025

🎯Projects on Pandas DataFrame with Matplotlib

 

🎯 Project 1: Student Marks Data Analysis + Bar Chart

Step 1: Create DataFrame

import pandas as pd import matplotlib.pyplot as plt data = { "Name": ["Amit", "Riya", "Sohan", "Neha", "Karan"], "Maths": [85, 92, 76, 88, 90], "Science": [78, 89, 84, 91, 87], "English": [80, 75, 88, 85, 90] } df = pd.DataFrame(data) print(df)

Step 2: Add Total & Average

df["Total"] = df["Maths"] + df["Science"] + df["English"] df["Average"] = df["Total"] / 3 print(df)

Step 3: Visualize Marks (Bar Plot)

plt.figure(figsize=(8,5)) plt.bar(df["Name"], df["Total"]) plt.title("Total Marks of Students") plt.xlabel("Students") plt.ylabel("Total Marks") plt.show()

✔ What You Learn

  • Bar chart

  • Column operations

  • Student performance comparison


🎯 Project 2: Store Sales Analysis + Line Chart

Step 1: Create DataFrame

data = { "Day": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], "Sales": [1200, 1500, 1600, 1700, 2000, 2500, 2200] } df = pd.DataFrame(data) print(df)

Step 2: Insights

print("Total Weekly Sales:", df["Sales"].sum()) print("Average Daily Sales:", df["Sales"].mean()) print("Highest Sales Day:", df.loc[df["Sales"].idxmax()])

Step 3: Visualize Sales (Line Chart)

plt.plot(df["Day"], df["Sales"], marker="o") plt.title("Weekly Sales Trend") plt.xlabel("Day") plt.ylabel("Sales (₹)") plt.grid(True) plt.show()

✔ What You Learn

  • Line graph

  • Insights for business

  • Day-wise performance


🎯 Project 3: Employee Attendance Tracker + Horizontal Bar Chart

Step 1: Create DataFrame

data = { "Employee": ["Amit", "Riya", "Sohan", "Neha"], "Mon": [1, 1, 1, 0], "Tue": [1, 1, 0, 1], "Wed": [1, 1, 1, 1], "Thu": [0, 1, 1, 1], "Fri": [1, 1, 1, 1] } df = pd.DataFrame(data) print(df)

Step 2: Calculate Total Present Days

df["Total_Present"] = df[["Mon", "Tue", "Wed", "Thu", "Fri"]].sum(axis=1) print(df)

Step 3: Visualize Attendance (Horizontal Bar Plot)

plt.barh(df["Employee"], df["Total_Present"]) plt.title("Weekly Attendance Report") plt.xlabel("Days Present") plt.ylabel("Employee") plt.show()

✔ What You Learn

  • Row-wise operations

  • Horizontal bar graph

  • HR-style attendance report


🎯 Project 4: Movie Rating Analyzer + Pie Chart

Step 1: Create DataFrame

data = { "Movie": ["Movie A", "Movie B", "Movie C", "Movie D"], "Rating": [4.5, 3.8, 4.2, 4.9], "Votes": [200, 150, 180, 220] } df = pd.DataFrame(data) print(df)

Step 2: Weighted Score

df["Weighted_Score"] = df["Rating"] * df["Votes"] print(df)

Step 3: Visualize Ratings (Pie Chart)

plt.pie(df["Rating"], labels=df["Movie"], autopct="%1.1f%%") plt.title("Movie Rating Distribution") plt.show()

✔ What You Learn

  • Pie charts

  • Weighted score calculation

  • Comparing multiple movies


🎉 BONUS PROJECT

Project 5: Daily Steps Tracker (Fitness) + Line Chart

Step 1: Create DataFrame

data = { "Day": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"], "Steps": [3500, 4200, 5000, 6000, 7500, 8200, 9000] } df = pd.DataFrame(data) print(df)

Step 2: Plot Steps Progress

plt.plot(df["Day"], df["Steps"], marker="o") plt.title("Weekly Steps Progress") plt.xlabel("Day") plt.ylabel("Steps") plt.grid(True) plt.show()

✔ What You Learn

  • Health data visualization

  • Understanding weekly progress

  • Line chart usage

8 comments:

  1. project 1 output-: Initial data:
    Name Maths Science English
    0 Amit 85 78 80
    1 Riya 92 89 75
    2 Sohan 76 84 88
    3 Neha 88 91 85
    4 Karan 90 87 90

    Data with Total and Average marks:
    Name Maths Science English Total Average
    0 Amit 85 78 80 243 81.000000
    1 Riya 92 89 75 256 85.333333
    2 Sohan 76 84 88 248 82.666667
    3 Neha 88 91 85 264 88.000000
    4 Karan 90 87 90 267 89.000000

    ReplyDelete
  2. #Project 1: Daily Temperature Analysis
    Monday 28
    Tuesday 29
    Wednesday 30
    Thursday 31
    Friday 29
    Saturday 28
    Sunday 30
    dtype: int64
    Average Temperature: 29.285714285714285
    Highest Temperature: 31
    Lowest Temperature: 28

    ReplyDelete
  3. Project 2: Monthly Sales Comparison
    Jan 12000
    Feb 15000
    Mar 13500
    Apr 16000
    May 17500
    Jun 19000
    dtype: int64
    Total Sales: 93000
    Average Sales: 15500.0
    Month with Highest Sales: Jun

    ReplyDelete
  4. Project 3: Student Marks Data Analysis + Bar Chart
    Name Maths Science English
    0 Amit 85 78 80
    1 Riya 92 89 75
    2 Sohan 76 84 88
    3 Neha 88 91 85
    4 Karan 90 87 90
    Name Maths Science English Total
    0 Amit 85 78 80 243
    1 Riya 92 89 75 256
    2 Sohan 76 84 88 248
    3 Neha 88 91 85 264
    4 Karan 90 87 90 267
    Name Maths Science English Total Average
    0 Amit 85 78 80 243 81.000000
    1 Riya 92 89 75 256 85.333333
    2 Sohan 76 84 88 248 82.666667
    3 Neha 88 91 85 264 88.000000
    4 Karan 90 87 90 267 89.000000

    ReplyDelete
  5. Project 4: Store Sales Analysis + Line Chart
    Day Sales
    0 Mon 1200
    1 Tue 1500
    2 Wed 1600
    3 Thu 1700
    4 Fri 2000
    5 Sat 2500
    6 Sun 2200
    Total Weekly Sales: 12700
    Average Daily Sales: 1814.2857142857142
    Highest Sales Day: Day Sat
    Sales 2500
    Name: 5, dtype: object

    ReplyDelete
  6. Project 5: Employee Attendance Tracker + Horizontal Bar Char
    Employee Mon Tue Wed Thu Fri
    0 Amit 1 1 1 0 1
    1 Riya 1 1 1 1 1
    2 Sohan 1 0 1 1 1
    3 Neha 0 1 1 1 1
    Employee Mon Tue Wed Thu Fri Total_Present
    0 Amit 1 1 1 0 1 4
    1 Riya 1 1 1 1 1 5
    2 Sohan 1 0 1 1 1 4
    3 Neha 0 1 1 1 1 4

    ReplyDelete
  7. Project 6: Movie Rating Analyzer + Pie Chart
    Movie Rating Votes
    0 Movie A 4.5 200
    1 Movie B 3.8 150
    2 Movie C 4.2 180
    3 Movie D 4.9 220
    Movie Rating Votes Weighted_Score
    0 Movie A 4.5 200 900.0
    1 Movie B 3.8 150 570.0
    2 Movie C 4.2 180 756.0
    3 Movie D 4.9 220 1078.0

    ReplyDelete
  8. Project 7: Daily Steps Tracker (Fitness) + Line Chart
    Day Steps
    0 Mon 3500
    1 Tue 4200
    2 Wed 5000
    3 Thu 6000
    4 Fri 7500
    5 Sat 8200
    6 Sun 9000

    ReplyDelete

Python Viva Questions

  Basic Python Viva Questions 1. What is Python? Python is a high-level, interpreted, and object-oriented programming language used for w...