Advance Computer Programming SY 2025-2026
- Name: Ruiz, Justin Danrei C || 2ECE-C
- Intended Learning Outcomes:
- To identify the codes and functions needed in cleaning and visualizing data
- 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
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
-
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.
- This uses
-
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.
- This uses
-
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.
- First, a copy of the dataset is created so the original
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
- Opens an Excel file called board2.xlsx (this has the student list).
- Looks at each student’s information (like Name, Gender, Hometown, Track, and Grades).
- Filters (picks out) the students that meet certain conditions.
- Example: “Show me all students from Visayas with Math below 70.”
- Calculates the average grade of each student across 4 subjects.
- Draws a bar chart to see performance by track.
- All of the questions taught us how to do data wrangling and how to apply this for future data management.
- 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
- Clone or download the repository
- 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
- Open the .ipynb file in Jupyter Notebook, preferably in the latest version
- Run all cells in order to test the program