# -*- coding: utf-8 -*-
"""Covid19222.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1k9MG7HamnLZ3sc_D6w3nhCu7fx9lYbIV
"""

# Commented out IPython magic to ensure Python compatibility.
import numpy as np 
import matplotlib.pyplot as plt 
import matplotlib.colors as mcolors
import pandas as pd 
import random
import math
import time
from sklearn.linear_model import LinearRegression, BayesianRidge
from sklearn.model_selection import RandomizedSearchCV, train_test_split
from sklearn.preprocessing import PolynomialFeatures
from sklearn.tree import DecisionTreeRegressor
from sklearn.svm import SVR
from sklearn.metrics import mean_squared_error, mean_absolute_error
import datetime
import operator 
plt.style.use('fivethirtyeight')
# %matplotlib inline 

pd.set_option('max_columns',50)

time_age=pd.read_csv("TimeAge.csv")
time_gender=pd.read_csv("TimeGender.csv")
time_province=pd.read_csv("TimeProvince.csv")

time_age.head()

time_gender.head()

time_province.head()

Male=time_gender[time_gender["sex"]=='male']
Male

X=Male['confirmed']
X.head(10)

X.hist()



Female=time_gender[time_gender["sex"]=='female']
Female

Y=Female['confirmed']
Y

plt.plot(X)
plt.plot(Y)
plt.legend(['male','female'])

X_dec=Male['deceased']
X_dec

Y_dec=Female['deceased']
Y_dec

plt.plot((X_dec/X)*100)
plt.plot((Y_dec/Y)*100)
plt.legend(['Male Decaesed Rate','Female Decaesed Rate'])
plt.show

time_age

Grup1=time_age[time_age["age"]=='0s']
Grup1

Grup2=time_age[time_age["age"]=='10s']
Grup3=time_age[time_age["age"]=='20s']
Grup4=time_age[time_age["age"]=='30s']
Grup5=time_age[time_age["age"]=='40s']
Grup6=time_age[time_age["age"]=='50s']
Grup7=time_age[time_age["age"]=='60s']
Grup8=time_age[time_age["age"]=='70s']
Grup9=time_age[time_age["age"]=='80s']

plt.title("confirmed")
plt.plot(Grup1["confirmed"],color="black")
plt.plot(Grup2["confirmed"])
plt.plot(Grup3["confirmed"])
plt.plot(Grup4["confirmed"])
plt.plot(Grup5["confirmed"])
plt.plot(Grup6["confirmed"])
plt.plot(Grup7["confirmed"])
plt.plot(Grup8["confirmed"],color="white")
plt.plot(Grup9["confirmed"],color="green")
plt.legend(["0-10","10-20","20-30","30-40","40-50"
                    ,"50-60","60-70","70-80","80+"])

plt.title("Deceased")
plt.plot(Grup1["deceased"],color="black")
plt.plot(Grup2["deceased"])
plt.plot(Grup3["deceased"])
plt.plot(Grup4["deceased"])
plt.plot(Grup5["deceased"])
plt.plot(Grup6["deceased"])
plt.plot(Grup7["deceased"])
plt.plot(Grup8["deceased"],color="white")
plt.plot(Grup9["deceased"],color="green")
plt.legend(["0-10","10-20","20-30","30-40","40-50"
                    ,"50-60","60-70","70-80","80+"])

G1csum=Grup1["confirmed"].sum()
G2csum=Grup2["confirmed"].sum()
G3csum=Grup3["confirmed"].sum()
G4csum=Grup4["confirmed"].sum()
G5csum=Grup5["confirmed"].sum()
G6csum=Grup6["confirmed"].sum()
G7csum=Grup7["confirmed"].sum()
G8csum=Grup8["confirmed"].sum()
G9csum=Grup9["confirmed"].sum()

G1dsum=Grup1["deceased"].sum()
G2dsum=Grup2["deceased"].sum()
G3dsum=Grup3["deceased"].sum()
G4dsum=Grup4["deceased"].sum()
G5dsum=Grup5["deceased"].sum()
G6dsum=Grup6["deceased"].sum()
G7dsum=Grup7["deceased"].sum()
G8dsum=Grup8["deceased"].sum()
G9dsum=Grup9["deceased"].sum()

labels = ['G1', 'G2', 'G3', 'G4', 'G5','G6','G7','G8','G9']
confirmed = [G1csum,G2csum,G3csum,G4csum,G5csum,G6csum,G7csum,G8csum,G9csum]
#deceased = [G1dsum*20,G2dsum*20,G3dsum*20,G4dsum*20,G5dsum*20,G6dsum*20,G7dsum*20,G8dsum*20,G9dsum*20]

x = np.arange(len(labels))  # the label locations
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects1 = ax.bar(x - width/2, confirmed, width,label='Confirmed')
#rects2 = ax.bar(x + width/2, deceased, width, label='Deceased')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

labels = ['G1', 'G2', 'G3', 'G4', 'G5','G6','G7','G8','G9']
deceased = [G1dsum*20,G2dsum*20,G3dsum*20,G4dsum*20,G5dsum*20,G6dsum*20,G7dsum*20,G8dsum*20,G9dsum*20]

x = np.arange(len(labels))  # the label locations
width = 0.35  # the width of the bars

fig, ax = plt.subplots()
rects2 = ax.bar(x + width/2, deceased, width, label='Deceased')

# Add some text for labels, title and custom x-axis tick labels, etc.
ax.set_ylabel('Scores')
ax.set_title('Scores by group and gender')
ax.set_xticks(x)
ax.set_xticklabels(labels)
ax.legend()

