text_plain_output_1.png
import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

data = pd.read_csv('/kaggle/input/suicide-attempts-in-shandong-china/SuicideChina.csv')

data = data.drop(columns=['Unnamed: 0', 'Person_ID'])

def bar_plot(variable):
    """
    input: variable ex: "Sex"
    output: bar plot & Value count.  
    """
    var = data[variable]
    varValue = var.value_counts()
    plt.figure(figsize=(9, 3))
    plt.bar(varValue.index, varValue)
    plt.xticks(varValue.index, varValue.index.values, rotation=45)
    plt.ylabel('Frequency')
    plt.title(variable)
    plt.grid()
    plt.show()
    print('{}: \n {}'.format(variable, varValue))
category1 = ['Hospitalised', 'Died', 'Urban', 'Sex', 'Education', 'Occupation', 'method', 'Year', 'Month']
for c in category1:
    bar_plot(c)