text_html_output_1.png
import arviz as az

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

import warnings

import numpy as np
import pandas as pd
import os
import seaborn as sns
import matplotlib
import matplotlib.pyplot as plt
import arviz as az
data = pd.read_csv('../input/global-disaster-risk-index-time-series-dataset/world_risk_index.csv')

(len(data['Year'].unique()), np.sort(data['Year'].unique()), len(data['Region'].unique()))

data.isna().sum().sum()

def summary(col1, col2, year):
    pivot = pd.pivot_table(data, values=[col1], index=['Year', col2], aggfunc={col1: [min, max, np.mean, np.std]})
    pivot = pivot.sort_values(by=(col1, 'mean')).reindex(np.sort(data['Year'].unique()), level=0)
    return pivot.loc[year, :]

data.isna().sum().sum()

data.loc[1292, 'WRI Category'] = 'Medium'
data.loc[1193, 'Vulnerability Category'] = 'Very Low'
data.loc[1202, 'Vulnerability Category'] = 'Very Low'
data.loc[1205, 'Vulnerability Category'] = 'Very Low'
data.loc[1858, 'Vulnerability Category'] = 'Very Low'
data.loc[1858, ' Lack of Adaptive Capacities'] = np.mean(data[' Lack of Adaptive Capacities'])

ys = ['WRI','Exposure','Vulnerability','Susceptibility','Lack of Coping Capabilities',' Lack of Adaptive Capacities']
fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(15, 12))
for ax,i in zip(axs.ravel(),ys):
    az.plot_kde(data[i],fill_kwargs={"alpha":0.5},ax=ax)
    ax.set_title(i)
    sns.despine()
plt.show()

import warnings
warnings.filterwarnings("ignore")
ys = ['WRI','Exposure','Vulnerability','Susceptibility','Lack of Coping Capabilities',' Lack of Adaptive Capacities']
fig, axs = plt.subplots(nrows=2, ncols=3, figsize=(15, 12))
for ax,i in zip(axs.ravel(),ys):
    sns.boxplot(data[i],ax=ax)
    ax.set_title(i)
    sns.despine()
plt.show()

sns.pairplot(data=data)
plt.show()