0% found this document useful (0 votes)
13 views7 pages

PR 1

Uploaded by

fhquwron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views7 pages

PR 1

Uploaded by

fhquwron
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

import pandas as pd

import matplotlib.pyplot as plt

import numpy as np

def read_from_csv():

df1=pd.read_csv("C:\\Users\\mukesh ji\\Desktop\\delhi.data.csv")

df2=pd.read_csv("C:\\Users\\mukesh ji\\Desktop\\cont.aqi.csv")

df=pd.read_csv("C:\\Users\\mukesh ji\\Desktop\\redn.csv",index_col=0,)

print(df1)

print(df2)

print(df)

return [df1,df2,df]

def line(df1):

plt.plot(df1['month'],df1['2021'],color="green")

plt.plot(df1['month'],df1['2022'],color="blue")

plt.plot(df1['month'],df1['2023'],color="orange")

plt.xlabel("months")

plt.ylabel("aqi range")

plt.title("air quality analisation of delhi")

plt.show()

def bar1(df2):

x=np.arange(len(df2.Countries))

plt.bar(x-0.3,df2['2021'],color='Yellow',width=0.3)

plt.bar(x+0.0,df2['2020'],color='Red',width=0.3)

plt.bar(x+0.3,df2['2022'],color='Blue',width=0.3)

plt.xlabel('Countries')

plt.ylabel('2020,2021,2022')

plt.title('Air Quality Index')


plt.legend()

plt.show()

def bar2(df):

x=np.arange(len(df.Cities))

plt.bar(x-0.3,df[ALockdown],label='AQI before lockdown',color='blue',width=0.3)

plt.bar(x-0.0,df[BLockdown],label='AQI after lockdown',color='cyan',width=0.3)

plt.bar(x+0.3,df[Reduction],label='Reduction',color='grey',width=0.3) plt.xlabel('Indian Cities')

plt.ylabel('AQI Values')

plt.title('AQI analysis before and after lockdown')

plt.legend()

plt.show()

def select_row(df):

l=list()

n=int(input("Enter No. Of Cities you want to select: ") )

print("Enter Specific City index you want:")

for i in range(n):

r=eval(input())

l.append(r)

print(df.iloc[l])

def select_col(df):

l=list()

ncol=int(input("Enter No. Of Criterias you want to select: ") )

print("Enter Specific Criteria you want:")

for i in range(ncol):

c=input()

l.append(c)

print(df[l])
def update_col(df):

l=list()

col=input("Enter Columns to be updated:")

print("Enter New Values:")

for i in range(len(df)):

c=input()

l.append(c)

df[col]=l

print(df)

return(df)

def update_row(df): l=len(df)

row=int(input("Enter Cities Index to be updated:"))

if row<l:

a=input(("Enter new value before lockdown "))

b=input(("Enter new value after lockdown "))

c=input(("Enter new value of Reduction "))

df.iloc[row]=[a,b,c]

print(df)

return(df)

else:

print("Cities Does not exists!!")

def delete_row(df):

row=input("enter city to be deleted:")

i=list(df.index)
if row in i:

df=df.drop(row)

print(df)

return(df)

else:

print("city not found in data")

def delete_col(df):

col=input("enter criteria to be deleted:")

colname=df.columns

if col in colname:

del df[col]

print(df)

return(df)

else:

print("criteria not founded")

def write_to_csv(df): df.to_csv("Updated analysis of cities.csv")

print("File created")

def add_row(df):

print("Enter new row details:")

state=input("Enter Name of the new City: ")

x=int(input("Enter City Data before Lockdown: "))

y=int(input("Enter City Data after Lockdown: "))

z=int(input("Enter Reduction in AQI Values: "))

df.loc[state]=[x,y,z]

print("New Row Added:")

print(df)
return(df)

print("------------------WELCOME TO AQI MANAGEMENT-------------------")

ans='Y'

while ans=='Y' or ans== 'y':

print ("1.READ CONTENT FROM CSV FILE")

print("2.ADD CITY DETAILS")

print("3.UPDATE COLUMN DETAILS")

print("4.UPDATE ROW DETAILS")

print("5.DELETE SPECIFIC ROW")

print("6.DELETE SPECIFIC COLUMN")

print("7.SELECTION OF SPECIFIC ROW WITH LABELS")

print("8.SELECTION OF SPECIFIC COLUMN WITH LABELS")

print("9.WRITE CONTENT TO CSV FILE")

print("10.CREATE CHARTS FROM DATAFRAME")

print("11.EXIT")

ch=int(input("\nEnter Your choice (1-12) : "))

if ch==1:

[df1,df2,df]=read_from_csv()

elif ch==2:

df= add_row(df)

elif ch==3:

df=update_col(df)

elif ch==4:

df=update_row(df)

elif ch==5:

delete_row(df)
elif ch==6:

delete_col(df)

elif ch==7:

select_row(df)

elif ch==8:

select_col(df)

elif ch==9:

write_to_csv(df)

elif ch==10:

print('a. City wise Analysis')

print('b. Country wise Analysis')

print('c. Analysis of Delhi ')

ch1=input("Enter your choice(a-c): ")

if ch1=='a':

line(df1)

elif ch1=='b':

bar1(df2)

elif ch1=='c':

bar2(df)

else:

print('Enter correct choice...!!')

elif ch==11:

exit()

else:

print('Enter correct choice...!!')

ans=input("Do you want to continue?(Y/N):")

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy