Part 2 - Functions

After loading the database we can use some of the functions of the class object Cases Frame.

[1]:
import arcovid19 as ac
[2]:
cases = ac.load_cases()

Using the method last_growth_rate and specifying the province argument of the function, we obtain the latest growth rate available for the whole country or by province.

If provincia = None, the method will yield the value of Argentina’s last growth rate.

[3]:
cases.last_growth_rate(provincia=None)
[3]:
0.05519270795952047

If you want to get the latest growth rate for any particular province, you must replace None for the full name of the province.

[4]:
cases.last_growth_rate(provincia='córdoba')
/home/docs/checkouts/readthedocs.org/user_builds/arcovid19/envs/latest/lib/python3.7/site-packages/arcovid19-0.6b0-py3.7.egg/arcovid19/cases.py:731: RuntimeWarning: divide by zero encountered in true_divide
  growth_rate = np.array((I_n / I_n_1) - 1)
/home/docs/checkouts/readthedocs.org/user_builds/arcovid19/envs/latest/lib/python3.7/site-packages/arcovid19-0.6b0-py3.7.egg/arcovid19/cases.py:731: RuntimeWarning: invalid value encountered in true_divide
  growth_rate = np.array((I_n / I_n_1) - 1)
[4]:
-0.002178649237472796

In the case that you want to estimate the growth rate in the period where we have data by province or country, you can use the grateful_full_period method.

Again, if the province argument equals None, the series shown corresponds to Argentina.

[5]:
cases.grate_full_period(provincia=None).head(5)
[5]:
2020-03-04           0
2020-03-05           1
2020-03-06           3
2020-03-07       0.125
2020-03-08    0.333333
Name: (ARG, growth_rate_C), dtype: object
[6]:
cases.grate_full_period(provincia='córdoba').head(5)
[6]:
2020-03-04    NaN
2020-03-05    NaN
2020-03-06    NaN
2020-03-07    0.0
2020-03-08    0.0
dtype: float64

In the case that you want the observations by date, that is, not cumulative, you can use the restore_time_serie method as shown in the next cell.

[7]:
cases.restore_time_serie().head(4)
[7]:
provincia_status Pcia_status 2020-03-03 00:00:00 2020-03-04 00:00:00 2020-03-05 00:00:00 2020-03-06 00:00:00 2020-03-07 00:00:00 2020-03-08 00:00:00 2020-03-09 00:00:00 2020-03-10 00:00:00 ... 2020-05-19 00:00:00 2020-05-20 00:00:00 2020-05-21 00:00:00 2020-05-22 00:00:00 2020-05-23 00:00:00 2020-05-24 00:00:00 2020-05-25 00:00:00 2020-05-26 00:00:00 2020-05-27 00:00:00 2020-05-28 00:00:00
cod_provincia cod_status
CABA C CABA_C CABA Casos Confirmados 1.0 0.0 0.0 4.0 1.0 2.0 1.0 1.0 ... 224.0 257.0 379.0 404.0 400.0 494.0 375.0 327.0 362.0 425.0
R CABA_R CABA Casos Recuperados 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ... 262.0 0.0 0.0 0.0 0.0 539.0 0.0 0.0 0.0 285.0
D CABA_D CABA Casos Muertos 0.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 ... 5.0 2.0 2.0 7.0 6.0 3.0 8.0 5.0 4.0 3.0
A CABA_A CABA Casos Activos 1.0 0.0 0.0 4.0 0.0 2.0 1.0 1.0 ... -43.0 255.0 377.0 397.0 394.0 -48.0 367.0 322.0 358.0 137.0

4 rows × 89 columns