'How to create Time-Series Plots for three countries
I am tasked with creating a function that contains 3 countries (US, Canada and China) as my inputs and then creating subplots with their COVID cases. I wanted to know how to best do this, as I was thinking of creating a dataframe with those countries and then running a for loop within to create the subplots. Please provide some tips and tricks as to how to complete this task.
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
df = pd.DataFrame(data=cases_raw).rename_axis("Country").reset_index()
df
df.index.tolist() #returns the list of countries
A = cases_raw.loc['US']
B = cases_raw.loc['China']
C = cases_raw.loc['Canada']
#Make US,China and Canada as inputs and create sub-plots
fig, axes = plt.subplots(nrows=1, ncols=3, figsize=(12,4), sharey=True)
country_groups = df.groupby("Country")
country_name = []
for (country_name, ax) in zip(country_groups.groups.keys(), axes.flatten()):
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

