Header Ads Widget

Corona (Covid-19) Related PY Codes

1. Covid-19 Visualization Using Python


from time import sleep
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
import pandas as pd

df=pd.read_csv("https://covid19.who.int/WHO-COVID-19-global-table-data.csv")
df=df.drop(['WHO Region' , 'Cases - cumulative total per 100000 population',
                   'Cases - newly reported in last 7 days per 100000 population',
                   'Deaths - cumulative total per 100000 population',
                   'Deaths - newly reported in last 7 days', 'Deaths - newly reported in last 7 days per 100000 population', 'Transmission Classification'], axis=1)
df=df.set_index('Name')

df['Recovered']=df['Cases - cumulative total'] -df['Deaths - cumulative total']
df=df.drop(['Cases - cumulative total', 'Deaths - newly reported in last 24 hours'], axis=1)

int=input("Enter Country:")
df.loc[[int]]

import matplotlib.pyplot as plt
recovered=df.at[int, 'Recovered']
Deaths=df.at[int, 'Deaths - cumulative total']
new24=df.at[int, 'Cases - newly reported in last 24 hours']
new7=df.at[int, 'Cases - newly reported in last 7 days']
f=plt.figure(figsize=(8,8))
font = {'family' : 'normal',
            'weight' : 'bold',
            'size' : 12}

plt.rc('font', **font)
plt.rcParams.update({'text.color' : "black", 'axes.labelcolor' : "black"})
plt.pie([recovered,Deaths,new24,new7], labels=['Recovered', 'Deaths', 'new Cases /24hr', 'new Cases /7days'], colors= ['lightgreen', 'red', 'pink', 'orange'], explode=(0.2,0.02,0.2,0.1), startangle = 180,autopct = '%1.1f%%')

#Displying The Plot
plt.title(int)
plt.legend()
plt.show()                


Output :-


This will print visualization of Corona Cases.



2. Design the shape of Corona!


import turtle
a=0
b=0
turtle.bgcolor("black")
turtle.speed("0")
turtle.pencolor("green")
turtle.penup()
turtle.goto(0, 200)
turtle.pendown()

while True:
      turtle.forward(a)
      turtle.right(b)
      a+=3
      b+=1
      if b==201:
          break
turtle.close()


Note :- This will draw the shape of CORONA in your pc!



3. Get Current Covid Updates


from covid import Covid
covid = Covid()
print( covid.get_total_active_cases())
print( covid.get_total_deaths())
print( covid.get_total_confirmed_cases())


Output :-


This will Print the active corona cases number in your Compiler!



Post a Comment

0 Comments