import pandas as pd import numpy as np ## Read data def read_data(path): try: df = pd.read_csv(path) return df except Exception as e: return e ## Return country list def return_country_list(df): return df['country'].unique() ## Return the answer def find_min_vac_day(): df = read_data('country_vaccination_stats.csv') # Read data country_list = return_country_list(df) # Return countries for country in country_list: country_rows = df[df['country'] == country] min_daily_vaccination = country_rows['daily_vaccinations'].min() # Find min dail_vacation in each country first_row_index = country_rows.index[0] # By the data observation write the first row in each country_row if np.isnan(min_daily_vaccination): # If value not exist df.loc[first_row_index, 'daily_vaccinations'] = 0.0 # Fill it with 0 else: df.loc[first_row_index, 'daily_vaccinations'] = min_daily_vaccination # Fill it with min value return df def main(): updated_df = find_min_vac_day() if __name__ == '__main__': main()