Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from datetime import datetime as dt
- import matplotlib.pyplot as plt
- import numpy as np
- # USEFUL FUNCTIONS
- def getColumns(data_frame):
- for col in data_frame:
- print(col)
- def FormatedDate():
- formated_date = dt.today()
- print(formated_date)
- FormatedDate()
- # grabbing daily updated data CSWSEGISandData/COVID 19
- df_confirmedUS= pd.read_csv("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv")
- df_confirmedGlobal = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv')
- df_deathsUS = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_US.csv')
- df_deathsGlobal = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv')
- df_recoveryGlobal = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv')
- # daily updated data with UID
- df_covid_19 = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv')
- def get_todays_global_death_count():
- deaths = df_deathsGlobal.iloc[:,[1,-1]].groupby('Country/Region').sum()
- #iloc test selects rows and columns from pandas data frames
- deaths_2 = df_deathsGlobal.iloc[:,[1,1]]
- print(deaths_2)
- todays_date = deaths.columns[0]
- print("\n Total number of Deaths as of... " ,todays_date )
- deaths = deaths.sort_values(by = todays_date, ascending = False)
- deaths = deaths[deaths[todays_date] > 0]
- #death test
- print(deaths, '\n the death data frame boi ' )
- #death index retrun single array instead of an array of arrays
- # deaths_index_con = np.concatenate(deaths.index, axis = None)
- #death values retrun single array instead of an array of arrays
- deaths_values_con = np.concatenate(deaths.values , axis = None)
- total_global_deaths = deaths_values_con.sum()
- print("total global deaths ..... " , total_global_deaths)
- print(deaths_values_con, '\n this is the death values concatenated')
- #checking values
- print(deaths.index , '\n death index printed boi ' )
- print(deaths.values , "\n death values printed son " )
- #type test
- print( ' \n deats.index datt type.... ', type(deaths.index))
- #plot
- # plt.xticks(ypos, deaths.index)
- #plt.bar( ypos,deaths_values_con)
- get_todays_global_death_count()
- #def get_todays_US_death_count():
- # USDeaths = df_confirmedUS.iloc[]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement