0% found this document useful (0 votes)
583 views25 pages

AQI Project

This document contains a project report on analyzing air quality index (AQI) data from various areas in Delhi, India. The project was developed using Python programming language. The report includes an introduction to the project, hardware and software used, Python modules used, details of the CSV data file, the source code of the Python project, and sample outputs. The project code contains menus for viewing the CSV data as a DataFrame, data visualization of AQI metrics, and operations on the DataFrame such as slicing, filtering columns, adding/deleting rows.

Uploaded by

visheshkaushal8
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)
583 views25 pages

AQI Project

This document contains a project report on analyzing air quality index (AQI) data from various areas in Delhi, India. The project was developed using Python programming language. The report includes an introduction to the project, hardware and software used, Python modules used, details of the CSV data file, the source code of the Python project, and sample outputs. The project code contains menus for viewing the CSV data as a DataFrame, data visualization of AQI metrics, and operations on the DataFrame such as slicing, filtering columns, adding/deleting rows.

Uploaded by

visheshkaushal8
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
You are on page 1/ 25

VIDYA MEMORIAL SR. SEC.

PUBLIC SCHOOL

INFORMATICS PRACTICES
(Code – 065)

Project Report
On
Air Quality Index
(SESSION: 2023-2024)

Submitted to: Submitted by:

Mrs. Mandeep Kaur NAME : Vishesh Kaushal

CLASS : 12th

ROLL NO :
INDEX

S No. Description
1. Certificate
2. Acknowledgement
3. Introduction
4. Hardware and Software used
5. Python Modules used
6. CSV file Details
7. Project Source Code
8. Sample Outputs of Project
9. Bibliography
CERTIFICATE
This is to certify that Vishesh Kaushal of class 12th has
successfully completed the Informatics Practices
project on Air Quality Index under my supervision in
the computer lab of Vidya Memorial Sr. Sec. Public
School in the session 2023-24. The work done by her
is original.

Mandeep Kaur

Informatics Practices Teacher


ACKNOWLEDGEMENT

I would like to express my sincere thanks of gratitude


to my subject teacher Mrs. Mandeep Kaur for her
vital support, guidance and encouragement. She
helped me for completing the project by giving
guidance, ideas and made this project easy and
accurate.

I would like to extend my gratitude to our principal


Mrs. Priya Tyagi who gave me the golden
opportunity to do this project and also providing me
all the facilities that was required.
I wish to thank my parents for their undivided support
and interest who inspired me and encouraged me to
go my own way, without which I would be unable to
complete my project.

Vishesh Kaushal
Introduction of the Project
The Project is based on Air Quality Index of different areas in Delhi (using data
source from www.aqi.in). The Project Main Menu includes:
1. Show CSV contents as DataFrame
2. Data Visualization
3. Data Frame Operation and Analysis
Different Operation of Data Visualization Menu are:
1. Pollutants - PM 2.5 ,PM10 and AQI Analysis
2. Nitrogen Dioxide (NO2)
3. O3, SO2 and CO Pollutant Analysis
Different Operation of Data Frame Operation and Analysis are:
1. Show Top Records as per user's choice
2. Show Bottom Records as per user's choice
3. Show DataFrame Index, Columns,Size and Shape
4. Slicing - index given as per user choice
5. Show Specific Columns - as per user's choice
6. Delete Specific Records as per user's choice
7. Add New Record
8. Show Specific row - as per user's choice
Hardware and Software Used

Hardware Used

• Intel Pentium/Celeron or similar processor


• 264 MB RAM and 4 GB HDD
• Standard I/O devices like monitor,
keyboard, mouse etc.

Software Used

• Microsoft Window 10 as operating system.


• Python IDLE as front end development
environment.
• Microsoft Office Excel for CSV file.
• Microsoft Office Word for documentation.
Python Libraries
1. PANDAS: Pandas or Python Pandas is a Python's
library for data analysis. Pandas is an open source,
BSD library built for Python programming language.
Pandas offer high-performance, easy-to-use data
structures and data analysis tools. Pandas are the
most popular library in the scientific Python
ecosystem for doing data analysis. Pandas are
capable of many task including:
i. It can read or write in many different data
formats (integer, float, double, etc.)
ii. It can calculate in all the possible ways data is
organized i.e., across rows and down columns
iii. It allows to apply operations to independent
group thin the data.
iv. It supports reshaping of data into different
forms.
v. It supports visualization by integrating
matplotlib and seaborn etc. libraries
2. MATPLOTLIB: for Data Visualization in Python, the
Matplotlib library's Pyplot interface is used. The
matplotlib is a Python library that provides many
interfaces and functionality for 2D-graphics similar to
MATLAB in various forms.
CSV File Details
AQI.csv
Area PM25 PM10 NO2 O3 SO2 CO AQI
Alipur 300 121 30 4 9 7 211
Ashok nagar 209 207 40 5 2 12 261
Bali nagar 265 344 32 4 10 23 240
Civil line 345 404 28 3.5 11 24 360
Dwarka 115 439 34 2.9 8 25 283
East patel 200 145 38 4.9 9 22 210
Narela 249 211 26 4.6 7 19 401
ISBT 400 353 41 4.4 8 18 337
Uttam nagar 350 465 33 4.9 11 17 300
Project
Source
Code
import pandas as pd
import matplotlib.pyplot as plt
#Area, PM25, PM10, NO2, O3, SO2, CO, AQI

csvFileDF=pd.read_csv("AQI.csv")
csvFileDF.set_index('Area',inplace=True)

opt=0
while opt!=4:
print("#"*52)
print("Project on Air Quality Index ")
print("#"*52)
print("1. Show CSV contents as DataFrame")
print("2. Data Visualization")
print("3. Data Frame Operation and Analysis")
print("4. Close Menu and Exit")
opt=int(input("Enter your choice from the Menu "))
if opt==1:
print(csvFileDF)
elif opt==2:
Vopt=0
while Vopt!=8:
print("$$$$$$$$$$ Data Visualization Menu $$$$$$$$$$")
print("1. Pollutants - PM 2.5 ,PM10 and AQI Analysis")
print("2. Nitrogen Dioxide (NO2)")
print("3. O3, SO2 and CO Pollutant Analysis")
print("4. Back to Main Menu ")
Vopt=int(input("Enter your choice from the Menu "))
if Vopt==1:
subDF=csvFileDF[ ['PM25','PM10','AQI']].head(5)
subDF.plot(kind='bar')
plt.title('Particulate Matter PM2.5, PM10 and AQI analysis in Cities')
plt.ylabel('Value of PM2.5,PM10 and AQI')
plt.xlabel('City Name ')
plt.show()
elif Vopt==2:
plt.hist(csvFileDF['NO2'].head(5),label='Nitrogen Dioxide (NO2)')
plt.title('Nitrogen Dioxide Concentration analysis in Cities')
plt.legend(loc="best")
plt.xlabel('Class interval of Pollutant Value ')
plt.ylabel('Frequencey ')
plt.show()
elif Vopt==3:
subDF=csvFileDF.head(5)
Y1=subDF[ 'O3']
Y2=subDF[ 'SO2']
Y3=subDF[ 'CO']
X=subDF.index
plt.plot(X,Y1,label='Ozone (O3)')
plt.plot(X,Y2,label='Sulpher Dioxide (SO2)')
plt.plot(X,Y3,label='Carbon Dioxide (CO)')
plt.title('O3, SO2 and CO Pollutants Analysis in Cities')
plt.legend(loc="best")
plt.xlabel("City Name")
plt.ylabel("Pollutants Value ")
plt.show()
elif Vopt==4:
break
else:
print("Invalid choice......")
elif opt==3:
DFopt=0
while DFopt!=9:
print("#"*52)
print("Data Analysis Menu")
print("#"*52)
print("1. Show Top Records as per user's choice")
print("2. Show Bottom Records as per user's choice")
print("3. Show DataFrame Index, Columns,Size and Shape")
print("4. Slicing - index given as per user choice")
print("5. Show Specific Columns - as per user's choice")
print("6. Delete Specific Records as per user's choice")
print("7. Add New Record ")
print("8. Show Specific row - as per user's choice")
print("9. Back to Main Menu")
DFopt=int(input("Enter your choice from the Menu "))
if DFopt==1:
print("**** Show Top Records as per user's choice ***")
print(" $$$$$$$$$ Total Records in DataFrame are:",len(csvFileDF)
,'$$$$$$$$$ ')
n=int(input("How many Top record(s) of the DataFrame ?"))
if n>len(csvFileDF):
print("Error...Records out of limit")
else:
df_slice=csvFileDF.head(n)
print(df_slice)
elif DFopt==2:
print("**** Show Bottom Records as per user's choice ***")
print("$$$$$$$$$ Total Records in DataFrame are:",len(csvFileDF)
,'$$$$$$$$$ ')
n=int(input("How many last records of the DataFrame ?"))
if n>len(csvFileDF):
print("Error...Records out of limit")
else:
df_slice=csvFileDF.tail(n)
print(df_slice)

elif DFopt==3:
print("**** Show DataFrame Index, Columns,Size and Shape ***")
print("$$$$$$$$$ Index of the DataFrame $$$$$$$$$ ")
print(csvFileDF.index)
print("$$$$$$$$$ Columns of the DataFrame $$$$$$$$$ ")
print(csvFileDF.columns)
print(" $$$$$$$$$ Size of the DataFrame : ",csvFileDF.size
,'$$$$$$$$$ ')
print(" $$$$$$$$$ Shape of the DataFrame:
",csvFileDF.shape,'$$$$$$$$$ ')
elif DFopt==4:
print("**** Slicing - index given as per user choice ***")
print("$$$$$$$$$ Total Rows of the DataFrame $$$$$$$$$ ")
print(" $$$$$$$$$ Total Records in DataFrame are:",len(csvFileDF)
,'$$$$$$$$$ ')
start=int(input("Enter Starting index for Slicing :"))
end=int(input("Enter Ending index for Slicing :"))
print("**** Sliced - Rows From ",start," index to ",end-1, "are : ")
print(csvFileDF[start:end])
elif DFopt==5:
print("**** Show Specific Columns - as per user's choice ***")
print("$$$$$$$$$ Columns of the DataFrame $$$$$$$$$ ")
print(csvFileDF.columns)
data=eval(input("Enter Columns Name List - ['columnName',.... ]
format :"))
print(csvFileDF[data])
elif DFopt==6:
print("**** Delete Specific Records as per user's choice***")
print("$$$$$$$$$ Index of the DataFrame $$$$$$$$$ ")
print(csvFileDF.index)
data=input("Enter City Name index to Delete Record :")
if data in csvFileDF.index:
csvFileDF=csvFileDF.drop(data,axis=0)
print("$$$$$$$$$ DataFrame after removing the record
$$$$$$$$$ ")
print(csvFileDF)
csvFileDF.to_csv("AQI.csv")
else:
print(data," Details not exist ..")
elif DFopt==7:
print("**** Add New Record ***")
L=csvFileDF.index
data=input("Enter City Name to Add Record :")
if data in L:
print("Details already exist...")
else:
tPM25=int(input("Pollutant PM2.5 Value= "))
tPM10=int(input("Pollutant PM10 Value = "))
tNO2=int(input("Nitrogen Dioxide (NO2) Value = "))
tO3=int(input("Ozone (O3)Value = "))
tSO2=int(input("Sulpher Dioxide (SO2) Value= "))
tCO=int(input("Carbon Dioxide (CO) Value= "))
tAQI=int(input("Air Quality Index Value = "))
csvFileDF.loc[data]=[tPM25,tPM10, tNO2,tO3 ,tSO2 ,tCO,tAQI]
csvFileDF.to_csv("AQI.csv")
print("$$$$$$$$$ DataFrame after Adding the record $$$$$$$$$
")
print(csvFileDF)
elif DFopt==8:
print("**** Show Specific row - as per user's choice ***")
print("$$$$$$$$$ Index of the DataFrame $$$$$$$$$ ")
print(csvFileDF.index)
data=input("Enter City Name index to show Record Details :")
print(csvFileDF.loc[data])
elif DFopt==9:
break

else:
print("Invalid choice......")
elif opt==4:
break
else:
print("Invalid choice......")
Sample
Outputs
of
Project
Main Menu
####################################################
Project on Air Quality Index
####################################################
1. Show CSV contents as DataFrame
2. Data Visualization
3. Data Frame Operation and Analysis
4. Close Menu and Exit

CSV contents as DataFrame


PM25 PM10 NO2 O3 SO2 CO AQI
Area
Alipur 300 121 30 4.0 9 7 211
Ashok nagar 209 207 40 5.0 2 12 261
Bali nagar 265 344 32 4.0 10 23 240
Civil line 345 404 28 3.5 11 24 360
Dwarka 115 439 34 2.9 8 25 283
East patel 200 145 38 4.9 9 22 210
Narela 249 211 26 4.6 7 19 401
ISBT 400 353 41 4.4 8 18 337
Uttam Nagar 350 465 33 4.9 11 17 300
Hari Nagar 345 150 35 2.0 10 22 380

Data Visualization Menu


$$$$$$$$$$ Data Visualization Menu $$$$$$$$$$
1. Pollutants - PM 2.5 ,PM10 and AQI Analysis
2. Nitrogen Dioxide (NO2)
3. O3, SO2 and CO Pollutant Analysis
4. Back to Main Menu
Enter your choice from the Menu
Bar Graph - Pollutants - PM 2.5 ,PM10 and AQI Analysis

Histogram Chart - Nitrogen Dioxide (NO2)


Line Chart - O3, SO2 and CO Pollutant Analysis

Data Frame Operation and Analysis


####################################################
Data Analysis Menu
####################################################
1. Show Top Records as per user's choice
2. Show Bottom Records as per user's choice
3. Show DataFrame Index, Columns,Size and Shape
4. Slicing - index given as per user choice
5. Show Specific Columns - as per user's choice
6. Delete Specific Records as per user's choice
7. Add New Record
8. Show Specific row - as per user's choice
9. Back to Main Menu
Enter your choice from the Menu
Show Top Records as per user's choice
**** Show Top Records as per user's choice ***
$$$$$$$$$ Total Records in DataFrame are: 10 $$$$$$$$$
How many Top record(s) of the DataFrame ?7
PM25 PM10 NO2 O3 SO2 CO AQI
Area
Alipur 300 121 30 4.0 9 7 211
Ashok nagar 209 207 40 5.0 2 12 261
Bali nagar 265 344 32 4.0 10 23 240
Civil line 345 404 28 3.5 11 24 360
Dwarka 115 439 34 2.9 8 25 283
East patel 200 145 38 4.9 9 22 210
Narela 249 211 26 4.6 7 19 401

Show Bottom Records as per user's choice


**** Show Bottom Records as per user's choice ***
$$$$$$$$$ Total Records in DataFrame are: 10 $$$$$$$$$
How many last records of the DataFrame ?6
PM25 PM10 NO2 O3 SO2 CO AQI
Area
Dwarka 115 439 34 2.9 8 25 283
East patel 200 145 38 4.9 9 22 210
Narela 249 211 26 4.6 7 19 401
ISBT 400 353 41 4.4 8 18 337
Uttam Nagar 350 465 33 4.9 11 17 300
Hari Nagar 345 150 35 2.0 10 22 380

Show DataFrame Index, Columns,Size and Shape


**** Show DataFrame Index, Columns,Size and Shape ***
$$$$$$$$$ Index of the DataFrame $$$$$$$$$
Index(['Alipur', 'Ashok nagar', 'Bali nagar', 'Civil line', 'Dwarka',
'East patel', 'Narela', 'ISBT', 'Uttam Nagar', 'Hari Nagar'],
dtype='object', name='Area')
$$$$$$$$$ Columns of the DataFrame $$$$$$$$$
Index(['PM25', 'PM10', 'NO2', 'O3', 'SO2', 'CO', 'AQI'], dtype='object')
$$$$$$$$$ Size of the DataFrame : 70 $$$$$$$$$
$$$$$$$$$ Shape of the DataFrame: (10, 7) $$$$$$$$$
Slicing - index given as per user choice
**** Slicing - index given as per user choice ***
$$$$$$$$$ Total Rows of the DataFrame $$$$$$$$$
$$$$$$$$$ Total Records in DataFrame are: 10 $$$$$$$$$
Enter Starting index for Slicing :4
Enter Ending index for Slicing :10
**** Sliced - Rows From 4 index to 9 are :
PM25 PM10 NO2 O3 SO2 CO AQI
Area
Dwarka 115 439 34 2.9 8 25 283
East patel 200 145 38 4.9 9 22 210
Narela 249 211 26 4.6 7 19 401
ISBT 400 353 41 4.4 8 18 337
Uttam Nagar 350 465 33 4.9 11 17 300
Hari Nagar 345 150 35 2.0 10 22 380

Show Specific Columns - as per user's choice


**** Show Specific Columns - as per user's choice ***
$$$$$$$$$ Columns of the DataFrame $$$$$$$$$
Index(['PM25', 'PM10', 'NO2', 'O3', 'SO2', 'CO', 'AQI'], dtype='object')
Enter Columns Name List - ['columnName',.... ] format :['PM25','PM10','AQI']
PM25 PM10 AQI
Area
Alipur 300 121 211
Ashok nagar 209 207 261
Bali nagar 265 344 240
Civil line 345 404 360
Dwarka 115 439 283
East patel 200 145 210
Narela 249 211 401
ISBT 400 353 337
Uttam Nagar 350 465 300
Hari Nagar 345 150 380
Delete Specific Records as per user's choice
Enter your choice from the Menu 6
**** Delete Specific Records as per user's choice***
$$$$$$$$$ Index of the DataFrame $$$$$$$$$
Index(['Alipur', 'Ashok nagar', 'Bali nagar', 'Civil line', 'Dwarka',
'East patel', 'Narela', 'ISBT', 'Uttam Nagar', 'Hari Nagar'],
dtype='object', name='Area')
Enter City Name index to Delete Record :Kirti Nagar
Kirti Nagar Details not exist ..

Add New Record in DataFrame


**** Add New Record ***
Enter City Name to Add Record :Kirti Nagar
Pollutant PM2.5 Value= 130
Pollutant PM10 Value = 140
Nitrogen Dioxide (NO2) Value = 3
Ozone (O3)Value = 20
Sulpher Dioxide (SO2) Value= 20
Carbon Dioxide (CO) Value= 10
Air Quality Index Value = 340
$$$$$$$$$ DataFrame after Adding the record $$$$$$$$$
PM25 PM10 NO2 O3 SO2 CO AQI
Area
Alipur 300 121 30 4.0 9 7 211
Ashok nagar 209 207 40 5.0 2 12 261
Bali nagar 265 344 32 4.0 10 23 240
Civil line 345 404 28 3.5 11 24 360
Dwarka 115 439 34 2.9 8 25 283
East patel 200 145 38 4.9 9 22 210
Narela 249 211 26 4.6 7 19 401
ISBT 400 353 41 4.4 8 18 337
Uttam Nagar 350 465 33 4.9 11 17 300
Hari Nagar 345 150 35 2.0 10 22 380
Kirti Nagar 130 140 3 20.0 20 10 340
Show Specific row - as per user's choice
**** Show Specific row - as per user's choice ***
$$$$$$$$$ Index of the DataFrame $$$$$$$$$
Index(['Alipur', 'Ashok nagar', 'Bali nagar', 'Civil line', 'Dwarka',
'East patel', 'Narela', 'ISBT', 'Uttam Nagar', 'Hari Nagar',
'Kirti Nagar'],
dtype='object', name='Area')
Enter City Name index to show Record Details :ISBT
PM25 400.0
PM10 353.0
NO2 41.0
O3 4.4
SO2 8.0
CO 18.0
AQI 337.0
Name: ISBT, dtype: float64
Bibliography

1. Text book used:


❖ By Priti Arora
❖ By Sumita Arora
2. Websites used:
❖ www.pythonworld.in
❖ www.geeksforgeeks.org
❖ www.w3schools.com
❖ Source - https://www.aqi.in/in/dashboard/india/delhi/new-delhi

You might also like