Skip to main content

COVID ANALYSIS | GRADE XII PROJECT (IP)

 

COVID ANALYSIS

GRADE XII PROJECT


import pandas as pd

import matplotlib.pyplot as plt

#import numpy as np


def showdata() :

  df=pd.read_csv(r"D:\GRADE XII PYTHON\covid_19.csv")

  print(df)

  input("Press any key to continue....")


def dataNoIndex():

  df=pd.read_csv(r"D:\GRADE XII PYTHON\covid_19.csv",index_col=0)

  print(df)

  input("Press any key to continue...")


def data_sorted():

  df=pd.read_csv(r"D:\GRADE XII PYTHON\covid_19.csv")

  print(df.sort_values(by=['Confirmed']))


def write_data():

  print("Insert data of particular districts in list form:")

  di=input("Enter Districts:")

  con_cases=eval(input("Enter no. of confirmed cases:"))

  rec=eval(input("Enter no. of recovered cases:"))

  deaths=eval(input("Enter deaths:"))

  active=eval(input("Enter active cases:"))

  d={'Districts':[di],'Confirmed':[con_cases],'Recovered':[rec],'Deaths':[deaths],'Active':[active]}

  df=pd.DataFrame(d)

  df.to_csv(r"C:\\Users\\Kirti Hora\\Desktop\\twitter\\covid1_19.csv", mode='a', index=False, header=False)

  #print(df)

  print("Data has been added.")

  input("Press any key to continue...")

  


def edit_data():

  df=pd.read_csv(r"C:\Users\Kirti Hora\Desktop\twitter/covid1_19.csv")

  di=input("Enter district to edit:")

  col=input("Enter column name to update:")

  val=input("Enter new value")

  df.loc[df[df['Districts']==di].index.values,col]=val

  df.to_csv(r"C:\Users\Kirti Hora\Desktop\twitter/covid1_19.csv",index=False)

  print("Record has been updated...")

  input("Press any key to continue...")


def delete_data():

  di=input("Enter district to delete data:")

  df=pd.read_csv(r"C:\Users\Kirti Hora\Desktop\twitter\covid1_19.csv")

  df=df[df.Districts!=di]

  df.to_csv(r"C:\Users\Kirti Hora\Desktop\twitter\covid1_19.csv",index=False)

  print("Record deleted...")


def show_graph():

    df=pd.read_csv(r"C:\Users\Kirti Hora\Desktop\twitter\covid1_19.csv")

    plt.barh(df['Districts'],df['Active'],color='r')

    plt.title('Number of Active Cases')

    plt.xlabel('No of Tests')

    plt.show()


def show_line():

    df=pd.read_csv(r"C:\Users\Kirti Hora\Desktop\twitter\covid1_19.csv")

    plt.plot(df['Districts'],df['Deaths'],color='r')

    plt.title('Number of Active Cases')

    plt.xlabel('No of Tests')

    plt.show()

    


def main_menu():

  ch=0

  print("                     ==============================")

  print("                             Main Menu")

  print("                     ==============================")

  while ch!=9:

    print("""

          1. Show DataFrame

          2. Data without index

          3. Data in Ascending order of Confirmed cases

          4. Add district data into CSV

          5. Edit a record

          6. Delete a record

          7. Active Covid Cases Graph

          8. Line Graph

          9. Exit

          """)

    ch=int(input("Enter your choice:"))

    if ch==1:

      showData()

    elif ch==2:

      dataNoIndex()

    elif ch==4:

      write_data()

    elif ch==3:

      data_sorted()

    elif ch==5:

      edit_data()

    elif ch==6:

      delete_data()

    elif ch==7:

      show_graph()

    elif ch==8:

      show_line()

      #print("Thank you for using our App, Hope to see you again!!")

      break

main_menu() #FUNCTION CALLING


Comments

Popular posts from this blog

CS - SORTING/SEARCHING ALGORITHMS

  SORTING ALGORITHMS                       SORTING ALGORITHM PDF LINK #Bubble Sort          ·        The outer loop iterates through the entire array. ·        The inner loop compares adjacent elements and swaps them if they are out of order. ·        The outer loop runs n times, and each pass moves the largest element to its correct position. arr=[3,8,5,2,1] n = len(arr) print(n) for i in range(n):  #traverse through all the elements         # Last i elements are already sorted, no need to check them         for j in range(0, n-i-1):              # Swap if the element found is greater than the next element              if arr[j] > arr[j+1]:               ...

GRADE XI - NESTED FOR LOOP

                                                         NESTED FOR LOOP 1. for var1 in range(3):      print(var1,"OUTER LOOP")          # 0 outer loop       1 outer loop      2 outer loop          for var2 in range(2):                  print(var2+1,"INNER LOOP")    #1  2 inner loop     1  2  inner loop   1 2 inner loop  2. Print the following pattern using for loop: 1  1 2  1 2 3  1 2 3 4  Sol: for r in range(1,5):   #ROWS     for c in range(1,r+1):   #COLUMNS         print(c,end=" ")     print() 3. Print the following pattern using for loop: @  @ @  @ @ @...