text_html_output_1.png
from wordcloud import WordCloud

import matplotlib.pyplot as plt

import pandas as pd

def visualize_word_counts(counts, show=True):
    wc = WordCloud(max_font_size=130, min_font_size=25, colormap='tab20', background_color='black', prefer_horizontal=0.95, width=2100, height=700, random_state=0)
    cloud = wc.generate_from_frequencies(counts)
    plt.axis('off')

data = pd.read_csv('../input/suicide-rates-worldwide-20002019/data.csv')

columns = ['Country', 'Year', 'ProbDyingBoth', 'ProbDyingMale', 'ProbDyingFemale', 'SuicideBoth', 'SuicideMale', 'SuicideFemale']
values = data.iloc[1:, :].values
data = pd.DataFrame(values, columns=columns)
for col in columns[2:]:
    data[col] = data[col].map(lambda x: x.split('[')[0]).astype('float')

data.sample(5)

countries = {val: df for val, df in data.groupby('Country')}
country_avg = data.groupby('Country').mean().reset_index()

fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(15, 6))
ax[0].plot([0, 60], [0, 60], linewidth=3, color='black')
sns.scatterplot(data=country_avg, x='ProbDyingMale', y='ProbDyingFemale', s=100, ax=ax[0])
ax[0].set_title('Dying rates by gender')
ax[1].plot([0, 100], [0, 100], linewidth=3, color='black')
sns.scatterplot(data=country_avg, x='SuicideMale', y='SuicideFemale', s=100, ax=ax[1])
ax[1].set_title('Suicide rates by gender')
plt.show()