This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| images = [] | |
| for file_name in image_files: | |
| images.append(imageio.imread(file_name)) | |
| gif_path = "movie.gif" | |
| imageio.mimsave(gif_path, images, fps=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| anim_path = pathlib.Path("anim/") | |
| anim_path.mkdir(parents=True, exist_ok=True) | |
| fig = plt.figure() | |
| image_files = [] | |
| for date in dates: | |
| is_earthday = ihme["date"]==date | |
| cv19 = contiguous_usa.merge(ihme[is_earthday], left_on="state", right_on="location_name") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| date_set = set([]) | |
| for d in ihme["date"].tolist(): | |
| if d >= "2020–03–23" and d <= "2020–04–01": | |
| date_set.add(d) | |
| dates = sorted(list(date_set)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def plot_choropleth (anim_path, date, cv19, cities): | |
| ax = gplt.choropleth( | |
| cv19, | |
| hue="deaths_per_mil", | |
| edgecolor="white", | |
| linewidth=5, | |
| cmap="Reds", | |
| alpha=0.8, | |
| projection=gcrs.AlbersEqualArea(), | |
| figsize=(30, 30) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ax = gplt.choropleth( | |
| cv19, | |
| hue="deaths_per_mil", | |
| edgecolor="white", | |
| linewidth=5, | |
| cmap="Reds", | |
| alpha=0.8, | |
| projection=gcrs.AlbersEqualArea(), | |
| figsize=(30, 30) | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| deaths_per_mil = cv19["deaths_mean"] / cv19["population"] * 1000000.0 | |
| cv19["deaths_per_mil"] = deaths_per_mil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cv19 = contiguous_usa.merge(ihme[is_earthday], left_on="state", right_on="location_name") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| is_earthday = ihme["date"]=="2020–04–22" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ihme = pd.read_csv("data/Hospitalization_all_locs.csv") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| wget https://ihmecovid19storage.blob.core.windows.net/latest/ihme-covid19.zip | |
| unzip ihme-covid19.zip | |
| mv 2020_*/Hospitalization_all_locs.csv data |