Skip to content

Repository for PA4 for the course "Advanced Computer Programming and Algorithms" for Ruiz, Justin Danrei C. 2ECE-C Student

Notifications You must be signed in to change notification settings

JustinTaito/ECE2112_Programming-Assignment-4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

ECE2112_Programming-Assignment-4

Advance Computer Programming SY 2025-2026

  • Name: Ruiz, Justin Danrei C || 2ECE-C
  • Intended Learning Outcomes:
  1. To identify the codes and functions needed in cleaning and visualizing data
  2. To be able to apply and use the different codes and functions in creating a Python program that will be used in data wrangling and data visualization

📝Contents of this Assignment 📝

This project looks at a list of students (from an Excel file) and helps answer questions like:

  • Which students are from Visayas with low Math grades?
  • Which students from Luzon are in the Instrumentation track and have high Electronics grades?
  • Which female students from Mindanao have good averages?
  • It also shows graphs to make the results easier to understand
  1. Vis

    • This uses df.loc with conditionals (==, <, &) to look for students whose Hometown is Visayas and Math score is below 70.
    • The table only shows the columns Name, Gender, Track, and Math, then assigns it to the variable Vis before printing it.
  2. Instru

    • This uses df.loc with conditionals to find students whose Track is Instrumentation, Hometown is Luzon, and Electronics score is above 70.
    • The table only shows the columns Name, GEAS, and Electronics, then assigns it to the variable Instru before printing it.
  3. Mindy

    • First, a copy of the dataset is created so the original df is not modified.
    • An Average column is calculated from Math, Electronics, GEAS, and Communication.
    • Using df.loc, it filters for students who are Female, from Mindanao, and with an Average ≥ 55.
    • The table is set to show only Name, Track, Electronics, and Average, then assigns it to the variable Mindy before printing it.

Importing Code:

# Library Import
import pandas as pd # Import Pandas as pd
import numpy as np # Import Numpy as np
import matplotlib.pyplot as plt # Import Matplotlib.pyplot as plt

Reading the board2.xlsx:

df = pd.read_excel('board2.xlsx') # reads the board2.xlsx and declare df as so
df # print df

Coding Vis, Instru, and Mindy:

Vis = df.loc[(df['Hometown'] == 'Visayas') & # Declaring Vs, where using .loc, checks if the Hometown is Visayas AND
             (df['Math'] < 70) # Checks if the following grades is less than 70
             , ['Name', 'Gender', 'Track', 'Math']] # After the following criteria, then makes a column with Name, Gender, Track, and Math
Vis # Print Vis

Instru = df.loc[(df['Track'] == 'Instrumentation') & # Using .loc, checks if the Tracks as Instrumentation AND
             (df['Hometown'] == 'Luzon') & # Checks if the hometown is Luzon AND
             (df['Electronics'] > 70) # Checks if the Electronics section is more than 70
             , ['Name', 'GEAS', 'Electronics']] # Makes a new columns with Name, GEAS, Electronics
Instru # print Instru

Mindy = df.copy() # Create a copy first so that we don't modify the original file (which is df)
Mindy["Average"] = Mindy[["Math","Electronics","GEAS","Communication"]].mean(axis=1) # Create an Average column first
Mindy = Mindy.loc[ # using .loc to locate the following criteria
    (Mindy["Gender"] == "Female") & # checks for those whose gender is female AND
    (Mindy["Hometown"] == "Mindanao") & # checks for those whose hometown is Mindanao AND
    (Mindy["Average"] >= 55), # checks for the average if it's greater than 55
    ["Name", "Track", "Electronics", "Average"]] # Then lists down the name, track, electronics, and average
Mindy # print Mindy

Graphing Vis, Instru, Mindy:

copy = df.copy() # Make a copy so df is untouched
copy["Average"] = copy[["Math","Electronics","GEAS","Communication"]].mean(axis=1) # Step 1: Add Average column, axis = 1 means that we only go by columns, not rows
copy # print copy

# Step 2: Group averages
avgTrack = copy.groupby("Track")["Average"].mean()
avgGender = copy.groupby("Gender")["Average"].mean()
avgHometown = copy.groupby("Hometown")["Average"].mean()

# Step 3: Plot results
avgTrack.plot(kind="bar", title="Average Grade by Track", ylabel="Average Score", xlabel="Track") # Track
plt.show() # show plot
avgGender.plot(kind="bar", title="Average Grade by Gender", ylabel="Average Score", xlabel="Gender") # Gender
plt.show() # show plot
avgHometown.plot(kind="bar", title="Average Grade by Hometown", ylabel="Average Score", xlabel="Hometown")# Hometown
plt.show() # show plot

What the Program Does

  1. Opens an Excel file called board2.xlsx (this has the student list).
  2. Looks at each student’s information (like Name, Gender, Hometown, Track, and Grades).
  3. Filters (picks out) the students that meet certain conditions.
    • Example: “Show me all students from Visayas with Math below 70.”
  4. Calculates the average grade of each student across 4 subjects.
  5. Draws a bar chart to see performance by track.

💭 Why it's useful 💭

  • All of the questions taught us how to do data wrangling and how to apply this for future data management.

Personal Notes

  • I use several resources online in my coding assignment; however, I try to use the code from the Basic Computing.ipynb, Pandas, Numpy, Data Wrangling.ipynb and the cheat sheet provided in Canvas as much as possible

📁How to run 📁

  1. Clone or download the repository
  2. The board2.xlsx is required to download and be placed in the same folder as the .py/.ipynb file in order for it to work
  3. Open the .ipynb file in Jupyter Notebook, preferably in the latest version
  4. Run all cells in order to test the program

About

Repository for PA4 for the course "Advanced Computer Programming and Algorithms" for Ruiz, Justin Danrei C. 2ECE-C Student

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published