import pandas as pd # Step 1: Read the dataset url = "https://www.piworks.net/Upload/Document/Original/country_vaccination_stats.csv" data = pd.read_csv(url) # Display the first few rows of the dataframe print(data.head()) # Step 2: Calculate the minimum daily vaccination number per country min_vaccinations = data.groupby('country')['daily_vaccinations'].min() # Step 3: Fill missing values with the minimum vaccination number per country def fill_missing_vaccinations(row): if pd.isnull(row['daily_vaccinations']): min_vacc = min_vaccinations[row['country']] return 0 if pd.isnull(min_vacc) else min_vacc else: return row['daily_vaccinations'] data['daily_vaccinations'] = data.apply(fill_missing_vaccinations, axis=1) # Display the first few rows after imputation print(data.head()) # Save the imputed data to a new CSV file (optional) data.to_csv('imputed_country_vaccination_stats.csv', index=False) ## answers country date daily_vaccinations vaccines 0 Argentina 12/29/2020 NaN Sputnik V 1 Argentina 12/30/2020 15656.0 Sputnik V 2 Argentina 12/31/2020 15656.0 Sputnik V 3 Argentina 1/1/2021 11070.0 Sputnik V 4 Argentina 1/2/2021 8776.0 Sputnik V country date daily_vaccinations vaccines 0 Argentina 12/29/2020 6483.0 Sputnik V 1 Argentina 12/30/2020 15656.0 Sputnik V 2 Argentina 12/31/2020 15656.0 Sputnik V 3 Argentina 1/1/2021 11070.0 Sputnik V 4 Argentina 1/2/2021 8776.0 Sputnik V