text_plain_output_1.png
import numpy as np

import pandas as pd

df_env = pd.read_csv('/kaggle/input/global-environmental-factors/env.csv')
df_airpol = pd.read_csv('/kaggle/input/pm25-global-air-pollution/pm25-global-air-pollution-2017.csv')
df_pop = pd.read_csv('/kaggle/input/world-population-by-country-state/country_population.csv')

df_env.isna().sum()

df_env.loc[df_env['Country_Region'].isin(['Norway', 'Finland', 'Iceland', 'Estonia']), 'wind'] = 4.689151
df_env.loc[df_env['Country_Region'].isin(['Maldives']), 'wind'] = np.mean([2.698925, 3.494908])
df_env.loc[df_env['Country_Region'].isin(['Bahrain']), 'wind'] = np.mean([3.728877, 3.173667, 4.525724])
df_env.loc[df_env['Country_Region'].isin(['Antigua and Barbuda']), 'wind'] = np.mean([3.586282, 3.378886, 2.749947])
df_env.loc[df_env['Country_Region'].isin(['Saint Vincent and the Grenadines']), 'wind'] = 3.515223
df_env.loc[df_env['Country_Region'].isin(['Malta']), 'wind'] = np.mean([3.078635, 2.648621])
df_env.loc[df_env['Country_Region'].isin(['Seychelles']), 'wind'] = 2.736786
df_env.loc[df_env['Country_Region'].isin(['Saint Kitts and Nevis']), 'wind'] = 3.515223
df_env.loc[df_env['Country_Region'].isin(['Grenada']), 'wind'] = 3.515223
df_env.loc[df_env['Country_Region'].isin(['Saint Lucia']), 'wind'] = 3.515223
df_env.loc[df_env['Country_Region'].isin(['Barbados']), 'wind'] = 3.515223
df_env.loc[df_env['Country_Region'].isin(['Monaco']), 'wind'] = np.mean([5.745106, 3.369222])
cols_na = ['accessibility_to_cities', 'elevation', 'aspect', 'slope', 'tree_canopy_cover', 'isothermality', 'rain_coldestQuart', 'rain_driestMonth', 'rain_driestQuart', 'rain_mean_annual', 'rain_seasonailty', 'rain_warmestQuart', 'rain_wettestMonth', 'rain_wettestQuart', 'temp_annual_range', 'temp_coldestQuart', 'temp_diurnal_range', 'temp_driestQuart', 'temp_max_warmestMonth', 'temp_mean_annual', 'temp_min_coldestMonth', 'temp_seasonality', 'temp_warmestQuart', 'temp_wettestQuart', 'cloudiness']
for c in cols_na:
    country = df_env.loc[df_env[c].isna(), 'Country_Region'].unique()
    print(c, country)
    if 'Maldives' in country:
        df_env.loc[df_env[c].isna(), c] = df_env[df_env['Country_Region'] == 'India'][c].mean()
    else:
        df_env.loc[df_env[c].isna(), c] = df_env[df_env['Country_Region'] == 'Denmark'][c].mean()