AQI Project
AQI Project
PUBLIC SCHOOL
INFORMATICS PRACTICES
(Code – 065)
Project Report
On
Air Quality Index
(SESSION: 2023-2024)
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
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
Software Used
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