Percentage Calculation and Graph Plotting from Excel Data Using Python

@Om_Sahoo June 13, 2026

Setting up environment

Create a virtual environment

Create a project directory Data_Analysis and change into that project directory

mkdir Data_Analysis 
cd Data_Analysis 

Creating a Data_Analysis virtual environment.

python -m venv Data_Analysis

Activate that virtual environment

.\Data_Analysis\Scripts\activate

Install pip

pip install pandas
pip install numpy
pip install matplotlib
pip install openpyxl 

create a studentinfo.xlsx excel file containing student mark

Code

import pandas as pd 
import numpy as np 
import matplotlib.pyplot as plt
df = pd.read_excel("studentinfo.xlsx")
df["Percentage"]= np.round((df["Total"]/300)*100,2)
print (df)
plt.bar(df["Student Name"],df["Percentage"])
plt.title("Student Percentage")
plt.xlabel("Student Name")
plt.ylabel("Percentage(%)")
plt.show()

make sure your excel file and code is in same environment / same folder

0 Likes
63 Views
0 Comments

Filters

No filters available for this view.

Reset All