Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
556
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.92 KB | None | 0 0
  1. import pandas as pd
  2. from datetime import datetime as dt
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5. # USEFUL FUNCTIONS
  6.  
  7.  
  8.  
  9.  
  10. def getColumns(data_frame):
  11.     for  col in data_frame:
  12.         print(col)
  13.  
  14.  
  15.  
  16.  
  17. def FormatedDate():
  18.     formated_date = dt.today()
  19.     print(formated_date)
  20.  
  21. FormatedDate()
  22.  
  23.  
  24. # grabbing daily updated data CSWSEGISandData/COVID 19
  25. 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")
  26. 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')
  27. 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')
  28. 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')
  29. 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')
  30. # daily updated data with UID
  31. df_covid_19 = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/UID_ISO_FIPS_LookUp_Table.csv')
  32.  
  33. def get_todays_global_death_count():
  34.    
  35.    
  36.    
  37.     deaths  = df_deathsGlobal.iloc[:,[1,-1]].groupby('Country/Region').sum()
  38.  
  39.  
  40.     #iloc test selects rows and columns from pandas data frames
  41.     deaths_2 = df_deathsGlobal.iloc[:,[1,1]]
  42.     print(deaths_2)
  43.     todays_date = deaths.columns[0]
  44.     print("\n Total number of Deaths as of... " ,todays_date )
  45.     deaths = deaths.sort_values(by = todays_date, ascending = False)
  46.     deaths = deaths[deaths[todays_date] > 0]
  47.    
  48.  
  49.     #death test
  50.     print(deaths, '\n  the death data frame boi '  )
  51.  
  52.  
  53.  
  54.  
  55.     #death index retrun single array instead of an array of arrays
  56.    # deaths_index_con = np.concatenate(deaths.index, axis = None)
  57.  
  58.  
  59.     #death values retrun single array instead of an array of arrays
  60.     deaths_values_con = np.concatenate(deaths.values , axis = None)
  61.    
  62.     total_global_deaths = deaths_values_con.sum()
  63.     print("total global deaths .....  "  , total_global_deaths)
  64.  
  65.  
  66.     print(deaths_values_con, '\n   this is the death values concatenated')
  67.  
  68.  
  69.     #checking  values
  70.     print(deaths.index , '\n death index printed boi ' )
  71.     print(deaths.values , "\n death values printed son " )
  72.    
  73.  
  74.     #type test
  75.     print( ' \n deats.index datt type.... ', type(deaths.index))
  76.    
  77.     #plot
  78.  
  79.    # plt.xticks(ypos, deaths.index)
  80.     #plt.bar( ypos,deaths_values_con)
  81.  
  82.  
  83. get_todays_global_death_count()
  84.  
  85.  
  86.  
  87.  
  88. #def get_todays_US_death_count():
  89.    
  90.  #   USDeaths  = df_confirmedUS.iloc[]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement