text_html_output_1.png
from collections import Counter

import matplotlib.pyplot as plt

import seaborn as sns

median_house = pd.read_csv('../input/fatal-police-shootings-in-the-us/MedianHouseholdIncome2015.csv', encoding='windows-1252')
percent_over = pd.read_csv('../input/fatal-police-shootings-in-the-us/PercentOver25CompletedHighSchool.csv', encoding='windows-1252')
percentage_people = pd.read_csv('../input/fatal-police-shootings-in-the-us/PercentagePeopleBelowPovertyLevel.csv', encoding='windows-1252')
kill = pd.read_csv('../input/fatal-police-shootings-in-the-us/PoliceKillingsUS.csv', encoding='windows-1252')
share_race = pd.read_csv('../input/fatal-police-shootings-in-the-us/ShareRaceByCity.csv', encoding='windows-1252')

percentage_people.poverty_rate.value_counts()

percentage_people.poverty_rate.replace(['-'], 0.0, inplace=True)
percentage_people.poverty_rate = percentage_people.poverty_rate.astype(float)
area_list = list(percentage_people['Geographic Area'].unique())
area_poverty_ratio = []
for i in area_list:
    x = percentage_people[percentage_people['Geographic Area'] == i]
    area_poverty_rate = sum(x.poverty_rate) / len(x)
    area_poverty_ratio.append(area_poverty_rate)
data = pd.DataFrame({'area_list': area_list, 'area_poverty_ratio': area_poverty_ratio})
new_index = data['area_poverty_ratio'].sort_values(ascending=False).index.values
sorted_data = data.reindex(new_index)
plt.xticks(rotation=45)

kill.name.value_counts()

separate = kill.name[kill.name != 'TK TK'].str.split()
a, b = zip(*separate)
name_list = a + b
name_count = Counter(name_list)
most_common_names = name_count.most_common(15)
x, y = zip(*most_common_names)
x, y = (list(x), list(y))

percent_over.percent_completed_hs.value_counts()

percent_over.percent_completed_hs.replace(['-'], 0.0, inplace=True)
percent_over.percent_completed_hs = percent_over.percent_completed_hs.astype(float)
area_list = list(percent_over['Geographic Area'].unique())
area_highschool = []
for i in area_list:
    x = percent_over[percent_over['Geographic Area'] == i]
    area_highschool_rate = sum(x.percent_completed_hs) / len(x)
    area_highschool.append(area_highschool_rate)
data = pd.DataFrame({'area_list': area_list, 'area_highschool_ratio': area_highschool})
new_index = data['area_highschool_ratio'].sort_values(ascending=True).index.values
sorted_data2 = data.reindex(new_index)
plt.figure(figsize=(15, 10))
sns.barplot(x=sorted_data2['area_list'], y=sorted_data2['area_highschool_ratio'])
plt.xticks(rotation=45)
plt.xlabel('States')
plt.ylabel('Highs School Graduet Rate')