import matplotlib

import pandas as ps

import string

fileR = ps.read_csv('../input/3-Airplane_Crashes_Since_1908.txt', sep=',')

matplotlib.rcParams['figure.figsize'] = (10, 5)
ops = fileR['Operator'].value_counts()[:20]

fileR['Date'] = ps.to_datetime(fileR['Date'])
fileR['year'] = fileR['Date'].dt.year
fileR['month'] = fileR['Date'].dt.month
fileR['day'] = fileR['Date'].dt.day
sub_years = [1900, 1910, 1920, 1930, 1940, 1950, 1960, 1970, 1980, 1990, 2000, 2010]
years_legend = list(string.ascii_letters[:len(sub_years)])
fileR['year_group'] = ''
for i in range(0, len(sub_years) - 1):
    fileR.loc[(sub_years[i + 1] > fileR['year']) & (fileR['year'] >= sub_years[i]), ['year_group']] = years_legend[i]

matplotlib.rcParams['figure.figsize'] = (10, 5)
fileR[['Fatalities', 'year_group']].groupby('year_group').count().plot(kind='bar', fontsize=14, legend=True, color='g', title='Fatalities based on decades')