Skip to content

weiztech/Rust-Analyze-Indonesia-Covid-19-Data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Analyze Indonesia Covid-19 Dataset using Rust

Dataset Source: https://www.kaggle.com/hendratno/covid19-indonesia

:dep plotly = { version = ">=0.6.0", features = ["plotly_ndarray"] }
:dep itertools-num = "0.1.3"
:dep ndarray = "0.15.4"
:dep polars ={ version = "0.19.0", features = ["ndarray"] }
use std::env;

use polars::prelude::*;
use plotly::common::{
    ColorScale, ColorScalePalette, DashType, Fill, Font, Line, LineShape, Marker, Mode, Title,
};
use plotly::{Bar, NamedColor, Plot, Rgb, Rgba, Scatter};
use plotly::layout::{Axis, BarMode, Layout, Legend, TicksDirection};
env::set_var("POLARS_FMT_MAX_COLS", "50");
env::set_var("POLARS_TABLE_WIDTH", "100");
let mut df = CsvReader::from_path("covid_19_indonesia_time_series_all.csv")?
            .with_ignore_parser_errors(true)
            .infer_schema(None)
            .has_header(true)
            .finish()?;
df.head(Some(5))
shape: (5, 38)
+----------+-------------------+-------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+-------------+-----------+-----------+----------+-----------+------------------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| Date     | Location ISO Code | Location    | New Cases | New Deaths | New Recovered | New Active Cases | Total Cases | Total Deaths | Total Recovered | Total Active Cases | Location Level | City or Regency | Province    | Country   | Continent | Island   | Time Zone | Special Status         | Total Regencies | Total Cities | Total Districts | Total Urban Villages | Total Rural Villages | Area (km2) | Population | Population Density | Longitude  | Latitude  | New Cases per Million | Total Cases per Million | New Deaths per Million | Total Deaths per Million | Total Deaths per 100rb | Case Fatality Rate | Case Recovered Rate | Growth Factor of New Cases | Growth Factor of New Deaths |
| ---      | ---               | ---         | ---       | ---        | ---           | ---              | ---         | ---          | ---             | ---                | ---            | ---             | ---         | ---       | ---       | ---      | ---       | ---                    | ---             | ---          | ---             | ---                  | ---                  | ---        | ---        | ---                | ---        | ---       | ---                   | ---                     | ---                    | ---                      | ---                    | ---                | ---                 | ---                        | ---                         |
| str      | str               | str         | i64       | i64        | i64           | i64              | i64         | i64          | i64             | i64                | str            | str             | str         | str       | str       | str      | str       | str                    | i64             | i64          | i64             | i64                  | i64                  | i64        | i64        | f64                | f64        | f64       | f64                   | f64                     | f64                    | f64                      | f64                    | str                | str                 | f64                        | f64                         |
+==========+===================+=============+===========+============+===============+==================+=============+==============+=================+====================+================+=================+=============+===========+===========+==========+===========+========================+=================+==============+=================+======================+======================+============+============+====================+============+===========+=======================+=========================+========================+==========================+========================+====================+=====================+============================+=============================+
| 3/1/2020 | ID-JK             | DKI Jakarta | 2         | 0          | 0             | 2                | 39          | 20           | 41              | -22                | Province       |                 | DKI Jakarta | Indonesia | Asia      | Jawa     | UTC+07:00 | Daerah Khusus Ibu Kota | 1               | 5            | 44              | 267                  | null                 | 664        | 10846145   | 16334.31           | 106.836118 | -6.204699 | 0.18                  | 3.6                     | 0.0                    | 1.84                     | 0.18                   | 51.28%             | 105.13%             | null                       | null                        |
+----------+-------------------+-------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+-------------+-----------+-----------+----------+-----------+------------------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 3/2/2020 | ID-JK             | DKI Jakarta | 2         | 0          | 0             | 2                | 41          | 20           | 41              | -20                | Province       |                 | DKI Jakarta | Indonesia | Asia      | Jawa     | UTC+07:00 | Daerah Khusus Ibu Kota | 1               | 5            | 44              | 267                  | null                 | 664        | 10846145   | 16334.31           | 106.836118 | -6.204699 | 0.18                  | 3.78                    | 0.0                    | 1.84                     | 0.18                   | 48.78%             | 100.00%             | 1.0                        | 1.0                         |
+----------+-------------------+-------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+-------------+-----------+-----------+----------+-----------+------------------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 3/2/2020 | IDN               | Indonesia   | 2         | 0          | 0             | 2                | 2           | 0            | 0               | 2                  | Country        |                 |             | Indonesia | Asia      |          |           |                        | 416             | 98           | 7230            | 8488                 | 74953                | 1916907    | 265185520  | 138.34             | 113.921327 | -0.789275 | 0.01                  | 0.01                    | 0.0                    | 0.0                      | 0.0                    | 0.00%              | 0.00%               | null                       | null                        |
+----------+-------------------+-------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+-------------+-----------+-----------+----------+-----------+------------------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 3/2/2020 | ID-RI             | Riau        | 1         | 0          | 0             | 1                | 2           | 0            | 3               | -1                 | Province       |                 | Riau        | Indonesia | Asia      | Sumatera | UTC+07:00 |                        | 10              | 2            | 169             | 268                  | 1591                 | 87024      | 6074100    | 69.8               | 101.805109 | 0.511648  | 0.16                  | 0.33                    | 0.0                    | 0.0                      | 0.0                    | 0.00%              | 150.00%             | null                       | null                        |
+----------+-------------------+-------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+-------------+-----------+-----------+----------+-----------+------------------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 3/3/2020 | ID-JK             | DKI Jakarta | 2         | 0          | 0             | 2                | 43          | 20           | 41              | -18                | Province       |                 | DKI Jakarta | Indonesia | Asia      | Jawa     | UTC+07:00 | Daerah Khusus Ibu Kota | 1               | 5            | 44              | 267                  | null                 | 664        | 10846145   | 16334.31           | 106.836118 | -6.204699 | 0.18                  | 3.96                    | 0.0                    | 1.84                     | 0.18                   | 46.51%             | 95.35%              | 1.0                        | 1.0                         |
+----------+-------------------+-------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+-------------+-----------+-----------+----------+-----------+------------------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
df.get_column_names()
["Date", "Location ISO Code", "Location", "New Cases", "New Deaths", "New Recovered", "New Active Cases", "Total Cases", "Total Deaths", "Total Recovered", "Total Active Cases", "Location Level", "City or Regency", "Province", "Country", "Continent", "Island", "Time Zone", "Special Status", "Total Regencies", "Total Cities", "Total Districts", "Total Urban Villages", "Total Rural Villages", "Area (km2)", "Population", "Population Density", "Longitude", "Latitude", "New Cases per Million", "Total Cases per Million", "New Deaths per Million", "Total Deaths per Million", "Total Deaths per 100rb", "Case Fatality Rate", "Case Recovered Rate", "Growth Factor of New Cases", "Growth Factor of New Deaths"]
df.dtypes()
[Utf8, Utf8, Utf8, Int64, Int64, Int64, Int64, Int64, Int64, Int64, Int64, Utf8, Utf8, Utf8, Utf8, Utf8, Utf8, Utf8, Utf8, Int64, Int64, Int64, Int64, Int64, Int64, Int64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Float64, Utf8, Utf8, Float64, Float64]
df.shape()
(21759, 38)
df.column("Location Level").unwrap().unique()
Ok(shape: (2,)
Series: 'Location Level' [str]
[
	"Country"
	"Province"
])

Analyze Data Based Location Level: Provinces

/* get only latest provinces data by sort using date & drop_duplicates */
let provinces = df
        .filter(&df.column("Location Level").unwrap().equal("Province"))
        .unwrap()
        .sort(&["Date"], true)
        .unwrap()
        .drop_duplicates(true, Some(&["Province".to_string()]))
        .unwrap();
provinces
shape: (34, 38)
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| Date     | Location ISO Code | Location         | New Cases | New Deaths | New Recovered | New Active Cases | Total Cases | Total Deaths | Total Recovered | Total Active Cases | Location Level | City or Regency | Province         | Country   | Continent | Island        | Time Zone | Special Status | Total Regencies | Total Cities | Total Districts | Total Urban Villages | Total Rural Villages | Area (km2) | Population | Population Density | Longitude  | Latitude  | New Cases per Million | Total Cases per Million | New Deaths per Million | Total Deaths per Million | Total Deaths per 100rb | Case Fatality Rate | Case Recovered Rate | Growth Factor of New Cases | Growth Factor of New Deaths |
| ---      | ---               | ---              | ---       | ---        | ---           | ---              | ---         | ---          | ---             | ---                | ---            | ---             | ---              | ---       | ---       | ---           | ---       | ---            | ---             | ---          | ---             | ---                  | ---                  | ---        | ---        | ---                | ---        | ---       | ---                   | ---                     | ---                    | ---                      | ---                    | ---                | ---                 | ---                        | ---                         |
| str      | str               | str              | i64       | i64        | i64           | i64              | i64         | i64          | i64             | i64                | str            | str             | str              | str       | str       | str           | str       | str            | i64             | i64          | i64             | i64                  | i64                  | i64        | i64        | f64                | f64        | f64       | f64                   | f64                     | f64                    | f64                      | f64                    | str                | str                 | f64                        | f64                         |
+==========+===================+==================+===========+============+===============+==================+=============+==============+=================+====================+================+=================+==================+===========+===========+===============+===========+================+=================+==============+=================+======================+======================+============+============+====================+============+===========+=======================+=========================+========================+==========================+========================+====================+=====================+============================+=============================+
| 9/9/2021 | ID-AC             | Aceh             | 230       | 11         | 190           | 29               | 35327       | 1636         | 27375           | 6316               | Province       |                 | Aceh             | Indonesia | Asia      | Sumatera      | UTC+07:00 | Daerah Khusus  | 18              | 5            | 289             | null                 | 6497                 | 57956      | 5247257    | 90.54              | 96.910522  | 4.225615  | 43.83                 | 6732.47                 | 2.1                    | 311.78                   | 31.18                  | 4.63%              | 77.49%              | 0.91                       | 0.37                        |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-BA             | Bali             | 256       | 16         | 404           | -164             | 109612      | 3690         | 101100          | 4822               | Province       |                 | Bali             | Indonesia | Asia      | Nusa Tenggara | UTC+08:00 |                | 8               | 1            | 57              | 80                   | 636                  | 5780       | 4216171    | 729.43             | 115.131714 | -8.369472 | 60.72                 | 25998.0                 | 3.79                   | 875.2                    | 87.52                  | 3.37%              | 92.23%              | 0.86                       | 0.8                         |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-BT             | Banten           | 134       | 3          | 260           | -129             | 130191      | 2640         | 125569          | 1982               | Province       |                 | Banten           | Indonesia | Asia      | Jawa          | UTC+07:00 |                | 4               | 4            | 155             | 313                  | 1238                 | 9663       | 10722374   | 1109.64            | 106.109004 | -6.456736 | 12.5                  | 12141.99                | 0.28                   | 246.21                   | 24.62                  | 2.03%              | 96.45%              | 1.23                       | 0.75                        |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-BE             | Bengkulu         | 29        | 0          | 111           | -82              | 22815       | 453          | 21668           | 694                | Province       |                 | Bengkulu         | Indonesia | Asia      | Sumatera      | UTC+07:00 |                | 9               | 1            | 129             | 172                  | 1341                 | 19919      | 1999539    | 100.38             | 102.338421 | -3.533584 | 14.5                  | 11410.13                | 0.0                    | 226.55                   | 22.66                  | 1.99%              | 94.97%              | 1.04                       | 0.0                         |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| ...      | ...               | ...              | ...       | ...        | ...           | ...              | ...         | ...          | ...             | ...                | ...            | ...             | ...              | ...       | ...       | ...           | ...       | ...            | ...             | ...          | ...             | ...                  | ...                  | ...        | ...        | ...                | ...        | ...       | ...                   | ...                     | ...                    | ...                      | ...                    | ...                | ...                 | ...                        | ...                         |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-SA             | Sulawesi Utara   | 114       | 6          | 310           | -202             | 33312       | 990          | 30409           | 1913               | Province       |                 | Sulawesi Utara   | Indonesia | Asia      | Sulawesi      | UTC+08:00 |                | 11              | 4            | 171             | 332                  | 1507                 | 13892      | 2641884    | 190.17             | 124.5212   | 1.259638  | 43.15                 | 12609.18                | 2.27                   | 374.73                   | 37.47                  | 2.97%              | 91.29%              | 0.72                       | null                        |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-SB             | Sumatera Barat   | 132       | 3          | 277           | -148             | 87935       | 2043         | 82353           | 3539               | Province       |                 | Sumatera Barat   | Indonesia | Asia      | Sumatera      | UTC+07:00 |                | 12              | 7            | 179             | 230                  | 928                  | 42013      | 5519245    | 131.37             | 100.465062 | -0.850253 | 23.92                 | 15932.43                | 0.54                   | 370.16                   | 37.02                  | 2.32%              | 93.65%              | 1.0                        | 0.5                         |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-SS             | Sumatera Selatan | 108       | 4          | 159           | -55              | 58738       | 2969         | 54308           | 1461               | Province       |                 | Sumatera Selatan | Indonesia | Asia      | Sumatera      | UTC+07:00 |                | 13              | 4            | 241             | 387                  | 2853                 | 91592      | 8217551    | 89.72              | 104.169465 | -3.216212 | 13.14                 | 7147.87                 | 0.49                   | 361.3                    | 36.13                  | 5.05%              | 92.46%              | 1.61                       | 0.44                        |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
| 9/9/2021 | ID-SU             | Sumatera Utara   | 431       | 7          | 900           | -476             | 100748      | 2573         | 82991           | 15184              | Province       |                 | Sumatera Utara   | Indonesia | Asia      | Sumatera      | UTC+07:00 |                | 25              | 8            | 450             | 693                  | 5417                 | 72981      | 14874889   | 203.82             | 99.051964  | 2.191894  | 28.98                 | 6773.03                 | 0.47                   | 172.98                   | 17.3                   | 2.55%              | 82.37%              | 0.94                       | 0.19                        |
+----------+-------------------+------------------+-----------+------------+---------------+------------------+-------------+--------------+-----------------+--------------------+----------------+-----------------+------------------+-----------+-----------+---------------+-----------+----------------+-----------------+--------------+-----------------+----------------------+----------------------+------------+------------+--------------------+------------+-----------+-----------------------+-------------------------+------------------------+--------------------------+------------------------+--------------------+---------------------+----------------------------+-----------------------------+
// Top 5 Provinces with Most Death Cases
let top_death_provinces = provinces
    .sort(&["Total Deaths"], true)
    .unwrap()
    .head(Some(5));

//println!("{:?}", top_death_provinces);
// Top 5 Provinces with Most Cases
let top_cases_province = provinces
    .sort(&["Total Cases"], true)
    .unwrap()
    .head(Some(5));
//println!("{:?}", top_cases_province);
// Top 5 Provinces with Recovered Cases
let top_recovered_province = provinces
    .sort(&["Total Recovered"], true)
    .unwrap()
    .head(Some(5));
//println!("{:?}", top_recovered_province);

Bar Chart - Traces Data & Display

let top_death_trace = Bar::new(
    top_death_provinces
        .column("Province")
        .unwrap()
        .utf8()
        .unwrap()
        .into_iter()
        .map(|x| x.unwrap().to_string())
        .collect(),
    top_death_provinces
        .column("Total Deaths")
        .unwrap()
        .i64()
        .unwrap()
        .into_iter()
        .map(|x| x.unwrap())
        .collect(),
)
.name("Top 5 Provinces with Most Death Cases")
.marker(Marker::new().color(NamedColor::DarkRed));

let top_cases_trace = Bar::new(
    top_cases_province
        .column("Province")
        .unwrap()
        .utf8()
        .unwrap()
        .into_iter()
        .map(|x| x.unwrap().to_string())
        .collect(),
    top_cases_province
        .column("Total Cases")
        .unwrap()
        .i64()
        .unwrap()
        .into_iter()
        .map(|x| x.unwrap())
        .collect(),
)
.name("Top 5 Provinces with Most Cases")
.marker(Marker::new().color(NamedColor::OrangeRed));

let top_recovered_trace = Bar::new(
    top_recovered_province
        .column("Province")
        .unwrap()
        .utf8()
        .unwrap()
        .into_iter()
        .map(|x| x.unwrap().to_string())
        .collect(),
    top_recovered_province
        .column("Total Recovered")
        .unwrap()
        .i64()
        .unwrap()
        .into_iter()
        .map(|x| x.unwrap())
        .collect(),
)
.name("Top 5 Provinces with Most Recovered Cases")
.marker(Marker::new().color(NamedColor::DarkBlue));
let layout = Layout::new()
    .title(Title::new("Indonesia Covid-19 - Top 5 Provinces Cases"))
    .x_axis(Axis::new().title(Title::new("Provinces")))
    .y_axis(Axis::new().title(Title::new("Number Cases")));

let mut bar_plot = Plot::new();
bar_plot.set_layout(layout);
bar_plot.add_trace(top_cases_trace);
bar_plot.add_trace(top_recovered_trace);
bar_plot.add_trace(top_death_trace);
bar_plot.lab_display()

Analyze Data Based Location Level: Country

let countries = df.filter(&df.column("Location Level").unwrap().equal("Country")).unwrap();
let countries_new_cases = countries
    .column("New Cases")
    .unwrap()
    .i64()
    .unwrap()
    .to_ndarray()
    .unwrap().to_owned();
println!("{:?}", countries_new_cases);
[2, 0, 0, 0, 2, ..., 176, 297, 278, 311, 245], shape=[642], strides=[1], layout=CFcf (0xf), const ndim=1
let countries_new_deaths = countries
    .column("New Deaths")
    .unwrap()
    .i64()
    .unwrap()
    .to_ndarray()
    .unwrap()
    .to_owned();
println!("{:?}", countries_new_deaths);
[0, 0, 0, 0, 0, ..., 11, 11, 10, 10, 8], shape=[642], strides=[1], layout=CFcf (0xf), const ndim=1
let countries_new_recovered = countries
    .column("New Recovered")
    .unwrap()
    .i64()
    .unwrap()
    .to_ndarray()
    .unwrap()
    .to_owned();
println!("{:?}", countries_new_recovered);
[0, 0, 0, 0, 0, ..., 419, 324, 307, 388, 328], shape=[642], strides=[1], layout=CFcf (0xf), const ndim=1

Scatter plot Trace Data & Display (Based: New Cases)

let new_vs_death_trace = Scatter::from_array(
        countries_new_cases.to_owned(),
        countries_new_deaths.to_owned(),
    )
.mode(Mode::MarkersText)
.name("New Cases vs New Death Cases");

let new_vs_recovered_trace = Scatter::from_array(
    countries_new_cases.to_owned(),
    countries_new_recovered.to_owned(),
)
.mode(Mode::MarkersText)
.name("New Case vs New Recovered Cases");

let death_vs_recovered_trace = Scatter::from_array(
    countries_new_deaths.to_owned(),
    countries_new_recovered.to_owned(),
)
.mode(Mode::MarkersText)
.name("New Death vs New Recovered Cases");
let mut scatter_plot = Plot::new();
scatter_plot.add_trace(new_vs_death_trace);
scatter_plot.add_trace(new_vs_recovered_trace);
scatter_plot.add_trace(death_vs_recovered_trace);
scatter_plot.lab_display()

Scatter plot Trace Data & Display (Based: Total Cases)

let countries_ttl_cases = countries
    .column("Total Cases")
    .unwrap()
    .i64()
    .unwrap()
    .to_ndarray()
    .unwrap().to_owned();
println!("{:?}", countries_ttl_cases);
[2, 2, 2, 2, 4, ..., 4256112, 4256409, 4256687, 4256998, 4257243], shape=[642], strides=[1], layout=CFcf (0xf), const ndim=1
let countries_ttl_deaths = countries
    .column("Total Deaths")
    .unwrap()
    .i64()
    .unwrap()
    .to_ndarray()
    .unwrap()
    .to_owned();
println!("{:?}", countries_ttl_deaths);
[0, 0, 0, 0, 0, ..., 143819, 143830, 143840, 143850, 143858], shape=[642], strides=[1], layout=CFcf (0xf), const ndim=1
let countries_ttl_recovered = countries
    .column("Total Recovered")
    .unwrap()
    .i64()
    .unwrap()
    .to_ndarray()
    .unwrap()
    .to_owned();
println!("{:?}", countries_ttl_recovered);
[0, 0, 0, 0, 0, ..., 4104333, 4104657, 4104964, 4105352, 4105680], shape=[642], strides=[1], layout=CFcf (0xf), const ndim=1
let ttl_case_vs_ttl_death_trace = Scatter::from_array(
        countries_ttl_cases.to_owned(),
        countries_ttl_deaths.to_owned(),
    )
.mode(Mode::MarkersText)
.name("Total Cases vs Total Death Cases");

let ttl_case_vs_ttl_recovered_trace = Scatter::from_array(
    countries_ttl_cases.to_owned(),
    countries_ttl_recovered.to_owned(),
)
.mode(Mode::MarkersText)
.name("Total Case vs Total Recovered Cases");

let ttl_death_vs_ttl_recovered_trace = Scatter::from_array(
    countries_ttl_deaths.to_owned(),
    countries_ttl_recovered.to_owned(),
)
.mode(Mode::MarkersText)
.name("Total Death vs Total Recovered Cases");
let mut ttl_scatter_plot = Plot::new();
ttl_scatter_plot.add_trace(ttl_case_vs_ttl_death_trace);
ttl_scatter_plot.add_trace(ttl_case_vs_ttl_recovered_trace);
ttl_scatter_plot.add_trace(ttl_death_vs_ttl_recovered_trace);
ttl_scatter_plot.lab_display()

About

Analyze Indonesia Covid-19 Data

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published