# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     name: python3
# ---

# + [markdown] id="view-in-github" colab_type="text"
# <a href="https://colab.research.google.com/github/theanshulcode/Prediction-of-India-Covid-19-Cases/blob/main/Prediction%20of%20India%20Covid-19%20Cases.ipynb" target="_parent"><img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/></a>

# + colab={"base_uri": "https://localhost:8080/", "height": 35} id="3e_wkGxQwVSf" outputId="96fad0c6-3777-4dcd-9067-1d4e5e4359c7"
import pandas as pd
import numpy as np
import seaborn as sns 
import matplotlib.pyplot as plt
import sklearn as sk
color = sns.color_palette()
# %matplotlib inline

import plotly.offline as py
from plotly import tools
py.init_notebook_mode(connected=True)
import plotly.graph_objs as go
import plotly.express as px
import os
os.getcwd()

# + colab={"base_uri": "https://localhost:8080/"} id="XkSsDY2JwZP8" outputId="640b81e6-0ec2-47d5-ba36-5db800ce36c4"
df = pd.read_csv("state_wise_daily.csv")
print("Dataset have been successfully imported.")

# + colab={"base_uri": "https://localhost:8080/", "height": 394} id="_ylKRBInw7UB" outputId="be7665ce-0a1e-4438-dfb4-fe3528fad0aa"
df.head()

# + colab={"base_uri": "https://localhost:8080/", "height": 394} id="qzxY1OMPw-TA" outputId="3720ea43-2d3b-4ceb-b0f0-3ea993ffcf66"
df.tail()

# + colab={"base_uri": "https://localhost:8080/"} id="8-2P4gXCw_8Y" outputId="13fa4152-1bed-424a-ede3-50d5412de437"
df.describe

# + colab={"base_uri": "https://localhost:8080/"} id="vGLaMXVixBV7" outputId="793f8005-c19d-4b52-95a4-56de9214342a"
df.info()

# + colab={"base_uri": "https://localhost:8080/"} id="S9QZa-k-xDCG" outputId="5e481e71-82a2-443a-9195-364d61cbe51e"
df.shape

# + id="vmHJfwCRxEBW"
statelist=list(df)
del statelist[:4]
statelist
df['Country Total']=df[statelist].sum(axis=1)

# + id="Bde-SXHixIG0"
#Converting to date time
df['Date']=pd.to_datetime(df['Date'],infer_datetime_format=True)

# + id="j9TGBrtCxJxa"
df_Confirmed=df.dropna()
df_Confirmed.drop([x for x in statelist], axis=1, inplace=True)
df_Confirmed.drop(['TT','Date_YMD'], axis=1, inplace=True)

# + id="TBV5HEV3xLS_"
df_Converted = pd.pivot_table(df_Confirmed, values='Country Total', index=['Date'],columns=['Status'])
df_Converted=df_Converted.reset_index()

# + colab={"base_uri": "https://localhost:8080/", "height": 204} id="hCz9WHeVxM7e" outputId="6a2bc09e-edbb-46c4-bef1-938e48550838"
df_Converted.head()

# + colab={"base_uri": "https://localhost:8080/"} id="Jk-0Qs6pxPe6" outputId="637a4bd2-1ac8-41e3-e4ce-c8f6a86a18ef"
print (df_Converted.head())

# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="sh8lgyxZxQ_U" outputId="a4dee58c-b300-4869-dbb3-4e2372fbd680"
# Creating graphical representation of daily count of covid cases in India
for Cols in df_Converted.columns:
    if Cols!='Date':
        fig = px.bar(df_Converted, x="Date", y=Cols)
        layout = go.Layout(
            title=go.layout.Title(
            text="Daily count of COVID-19 "+ Cols + " cases in India",
            x=0.5
            ),
            font=dict(size=14),
            width=1040,
            height=600,
            xaxis_title = "Date of observation",
            yaxis_title = "Number of "+ Cols + " cases"
            )
        fig.update_layout(layout)
        fig.show()

# + id="tOqRMRHXxTAa"
India=df_Converted

# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="clOW2OU2xoFJ" outputId="11ccc44c-5251-4734-b746-74dfeb76fa0a"
# Creating graphical representation of daily count of covid cases in India
for Cols in India.columns:
    if Cols!='Date':
        fig = px.bar(India, x="Date", y=Cols)
        layout = go.Layout(
            title=go.layout.Title(
            text="Daily count of COVID-19 "+ Cols + " cases in India",
            x=0.5
            ),
            font=dict(size=14),
            width=1040,
            height=600,
            xaxis_title = "Date of observation",
            yaxis_title = "Number of "+ Cols + " cases"
            )
        fig.update_layout(layout)
        fig.show()

# + colab={"base_uri": "https://localhost:8080/", "height": 204} id="CCsrQhVhxuZe" outputId="8f85e80d-0a3e-4b66-b71d-ff1f407d1bbd"
CFR = (India["Deceased"] / India["Confirmed"])*100
India["CFR"] = CFR
India.head()

# + colab={"base_uri": "https://localhost:8080/", "height": 1000} id="Wc9wQLlEyAxE" outputId="903917cd-4a3b-46d6-b5d4-295255ddd190"
# Creating graphical representation of daily count of of Confirmation covid cases vs CFR in India
for Cols in India.columns:
    if Cols!='Date':
        if Cols!='Confirmed':
            fig = px.bar(India, x="Date", y=Cols)
            layout = go.Layout(
                title=go.layout.Title(
                text="Daily count of COVID-19 "+ Cols + " cases in India",
                x=0.5
                ),
                font=dict(size=14),
                width=1040,
                height=600,
                xaxis_title = "Date of observation",
                yaxis_title = "Number of "+ Cols + " cases"
                )
            fig.update_layout(layout)
            fig.show()

# + colab={"base_uri": "https://localhost:8080/"} id="GBBlPcdvyFmO" outputId="1d5c404c-1d33-458d-b9b0-d57e51367bbe"
print('The average CFR of India is ',India.CFR.mean())

# + id="DugmmdTVyKo3"


StarcoderdataJupyterScriptsDedupFiltered