Enfim, decidi reassistir algumas das últimas aulas e adaptar os códigos. Compreendi que os vídeos estão atrasados, mas poderei me adaptar para ciência de dados na prática.
Procurei em qual data os dados de recovered
terminavam:
#Procurando onde os dados de recovered terminam
recovered_transpose['Brazil'][['7/30/21','8/1/21','8/2/21','8/3/21','8/3/21','8/4/21','8/5/21','8/6/21']]
7/30/21 17771228
8/1/21 17771228
8/2/21 17771228
8/3/21 17771228
8/3/21 17771228
8/4/21 17771228
8/5/21 0
8/6/21 0
Name: Brazil, dtype: object
Defini a variável: last_date = '8/4/21'
.
Tracei o gráfico para observação dos valores:
recovered_transpose = recovered.transpose().loc['1/22/20':last_date]
recovered_transpose.columns = list(recovered["Country/Region"].values)
recovered_transpose[['Brazil', 'Russia', 'India']].plot(figsize=(10,2))
Em seguida, usei a variável last_date
para diversas células do notebook, pois é onde os valores terminavam.
def latest_by_country(data):
return data.groupby("Country/Region").sum().loc[:,last_date]
display(latest_by_country(confirmed).head())
display(latest_by_country(deaths).head())
display(latest_by_country(recovered).head())
informations = [latest_by_country(confirmed), latest_by_country(deaths), latest_by_country(recovered)]
combined = pd.concat(informations, axis=1)
combined.columns = ["confirmed", "deaths", "recovered"]
letality_rate_1 = combined["deaths"] / combined["confirmed"] * 100
letality_rate_2 = combined["deaths"] / (combined["recovered"] + combined["deaths"]) * 100
combined["letality_rate_1"] = letality_rate_1
combined["letality_rate_2"] = letality_rate_2
combined
Country/Region | confirmed | deaths | recovered | letality_rate_1 | letality_rate_2 |
---|
Afghanistan | 148933 | 6836 | 82586 | 4.58998341536127 | 7.644651204401601 |
Albania | 133310 | 2457 | 130314 | 1.8430725376940964 | 1.8505547145084393 |
Algeria | 176724 | 4404 | 118409 | 2.492021457187479 | 3.585939599228095 |
Andorra | 14797 | 128 | 14380 | 0.8650402108535513 | 0.8822718500137855 |
Angola | 43158 | 1026 | 39582 | 2.377311274850549 | 2.5265957446808507 |
Antarctica | 0 | 0 | 0 | NaN | NaN |
Antigua and Barbuda | 1311 | 43 | 1239 | 3.279938977879481 | 3.3541341653666144 |
Outras linhas omitidas... | | | | | |