<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Effect of September-11 Terrorist Attack on Hate Crimes Against Muslims in the United Stateds
Course
Step1:  Data Import (2005 - 2015)
Files for years 2005-2015 are available in excel format. The files are downloaded into the working directory, and then imported using pandas library. For the above-mentioned years,the data is available in different tables and these tables categorise the data differently. We have used Table1, since it categorises the hate criimes against religion into different religions, which is most appropriate for this project. For example, for year 2015, we will get Table 1 from the source.
2015 Data
Download Source = https
Step2:  2014 Data
Download Source = https
Step3:  2013 Data
Download Source = https
Step4:  2012 Data
Download Source = https
Step5:  2011 Data
Download Source = https
Step6:  2010 Data
Download Source = https
Step7:  2009 Data
Download Source = https
Step8:  2007 Data
Download Source = https
Step9:  2006 Data
Download Source = https
Step10:  2005 Data
Download Source = https
Step11:  Data Web Scraping
Step12:  Data Import 1996 - 2004
Files for yeas 1995-2003, Table 1s are available within pdf reports, and will require a seperate importation technique as compared to the excel files. The relevant data is manually copied from each pdf file seperate, and stored into seperte local files.  
Steps for Data Collection using example of 2003
Step13:  DataFrame Description for a particular year
Headers
Step14:  Combining DataFrames for all years into one DataFrame
all_years is the list of the DataFrames for all years.
We want to combine the data for all the years into one DataFrame so that it can be used for analysis.
Folloing Steps Are taken for Combining the Data
Step15:  Q
Step16:  Answer
Step17:  Q 
Step18:  Answer
Step19:  Answer
Step20:  Answer
The ratio being discussed is shown above. Hate crimes targetting Muslims as a ratio of the hate-crimes motivated by religion has increased a lot in 2011 because of September-11 terrorist attack.Before, 2011, it was below 3% consistently, and in 2011 it went beyond 25%. After 2011, it never went down to its pre-2011 number. This also shows that the September-11 incident has increased the general sentiment against Muslims, and even after over a decade, the effect of September-11 on hate crimes against Muslims is clearly evident. Moreover, we can also see that the ratio has been rising in recent years showing that even though the number of hate-crimes against religions as a whole are decreasing, among those numbers, the ratio of attacks on Muslims in increaseing.
Q
<ASSISTANT_TASK:>
Python Code:
import sys                             # system module 
import pandas as pd                    # data package
import matplotlib.pyplot as plt        # graphics module  
import datetime as dt                  # date and time module
import numpy as np                     # foundation for pandas 
import requests
from bs4 import BeautifulSoup
%matplotlib inline                     
# check versions (overkill, but why not?)
print('Python version: ', sys.version)
print('Pandas version: ', pd.__version__)
print('Today: ', dt.date.today())
plt.style.use('ggplot')
Explanation: Effect of September-11 Terrorist Attack on Hate Crimes Against Muslims in the United Stateds
Course: Data Bootcamp
Report Author: Muaz Ahmad
Report Date: May 12, 2017
New York University
Leonard N. Stern School of Business
Image Source = http://www.huffingtonpost.com/entry/hate-crimes-muslims-since-911_us_57e00644e4b04a1497b59970
Research Question:
Main Research Question:
Q: Did September-11 terrorist attack have an impact on hate crimes against Muslims? How much and what impact did the incident have?
Analysis Questions: I will be using the data to answer the following questions. Answers to the following questions will be used to answer the main research question.
How have the hate crimes against Muslims changed in terms of number of incidents per year?
Did September-11 Terrorist Attack had an impact on the hate crimes against Muslims? If so, how much impact did September-11 Terrorist Attack had?
How have the hate crimes against All religion changed in terms of number of incidents per year?
What percentage of hate crimes motivated by religion identity target Muslims every year?
On average what percentages of attacks motivated by religion targetted Muslims, before and after the September-11 Terrorist Attack?
Data Source
The project focuses on the affect of 9/11 incident on the change in the hate crimes against Muslims in the United States. The data used for the project has been collected as Hate Crime Statistics through the Uniform Crime Reporting (UCR) Program of Federal Bureau of Investigation (FBI). The data is avialable on from FBI's website, where the data is reported on an yearly basis.  
The data is available for years 1995 to 2015, except 2009.
For each year: The data has been divided into different tables, based on the following aspects:
Incidents and Offenses
Victims
Offenders
Location Type
Hate Crime by Jurisdication
The projects uses the data categorised based on Incidents and Offenses, since the data is categorised into different types of hate crimes including Anti-Religion. The project utelises the data from year 1995-2015.
Limitations of the Data:
The data does not include the statistics for Hawaii. The data is not reported for Hawaii in the records.
The FBI collects data from independent law-enforcing agencies in different towns, cities, counties, metropolitan areas and university areas. Therefore, the data is contingent upon their reporting.
There is no data available for 2009.
Preliminaries
End of explanation
url = 'table1_2015.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2015 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E", headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2015 = data_2015[12:27]
#columns = ['Incidents','Offenses', 'Victims','Known Offenders']
#original_2015 = religion_2015.copy(deep=True)
#for col in columns:
 #   new_val = religion_2015.iloc[5][col] + religion_2015[col][7:14].sum()
      #print(new_val)
    #religion_2015 = religion_2015.set_value('Anti-Other Religion',col,new_val)
    #religion_2015.ix['Anti-Other Religion',col] = new_val
religion_2015
Explanation: Data Import (2005 - 2015)
Files for years 2005-2015 are available in excel format. The files are downloaded into the working directory, and then imported using pandas library. For the above-mentioned years,the data is available in different tables and these tables categorise the data differently. We have used Table1, since it categorises the hate criimes against religion into different religions, which is most appropriate for this project. For example, for year 2015, we will get Table 1 from the source.
2015 Data
Download Source = https://ucr.fbi.gov/hate-crime/2015/tables-and-data-declarations/1tabledatadecpdf
The file is saved locally as "table1_2015.xls"
End of explanation
url = 'table1_2014.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2014 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2014 = data_2014[9:17]
Explanation: 2014 Data
Download Source = https://ucr.fbi.gov/hate-crime/2014/tables/table-1
The file is saved locally as "table1_2014.xls"
End of explanation
url = 'table1_2013.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2013 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2013 = data_2013[9:17]
Explanation: 2013 Data
Download Source = https://ucr.fbi.gov/hate-crime/2013/tables/1tabledatadecpdf/table_1_incidents_offenses_victims_and_known_offenders_by_bias_motivation_2013.xls
The file is saved locally as "table1_2013.xls"
End of explanation
url = 'table1_2012.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2012 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2012 = data_2012[8:16]
Explanation: 2012 Data
Download Source = https://ucr.fbi.gov/hate-crime/2012/tables-and-data-declarations/1tabledatadecpdf/table_1_incidents_offenses_victims_and_known_offenders_by_bias_motivation_2012.xls
The file is saved locally as "table1_2012.xls"
End of explanation
url = 'table1_2011.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2011 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2011 = data_2011[8:16]
Explanation: 2011 Data
Download Source = https://ucr.fbi.gov/hate-crime/2011/tables/table-1
The file is saved locally as "table1_2011.xls"
End of explanation
url = 'table1_2010.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2010 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2010 = data_2010[7:15]
Explanation: 2010 Data
Download Source = https://ucr.fbi.gov/hate-crime/2010/tables/table-1-incidents-offenses-victims-and-known-offenders-by-bias-motivation-2010.xls
The file is saved locally as "table1_2010.xls"
End of explanation
url = 'table1_2008.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2008 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2008 = data_2008[7:15]
Explanation: 2009 Data
Download Source = https://ucr.fbi.gov/hate-crime/2010/tables/table-1-incidents-offenses-victims-and-known-offenders-by-bias-motivation-2010.xls
The file is saved locally as "table1_2010.xls"
2008 Data
Download Source = https://ucr.fbi.gov/hate-crime/2008
The file is saved locally as "table1_2008.xls"
End of explanation
url = 'table1_2007.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2007 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2007 = data_2007[7:15]
Explanation: 2007 Data
Download Source = https://ucr.fbi.gov/hate-crime/2007
The file is saved locally as "table1_2007.xls"
End of explanation
url = 'table1_2006.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2006 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2006 = data_2006[7:15]
Explanation: 2006 Data
Download Source = https://ucr.fbi.gov/hate-crime/2006
The file is saved locally as "table1_2006.xls"
End of explanation
url = 'table1_2005.xls'
headers = ['Incidents','Offenses','Victims1','Known offenders2']
data_2005 = pd.read_excel(url, skiprows=3, skipfooter=3, parse_cols="A,B,C,D,E",headers = None, names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])
religion_2005 = data_2005[7:15]
Explanation: 2005 Data
Download Source = https://ucr.fbi.gov/hate-crime/2005
The file is saved locally as "table1_2005.xls"
End of explanation
target = 'source_2004.txt'
target = open(target, "w")
url = "https://www2.fbi.gov/ucr/hc2004/hctable1.htm"
data_2004 = requests.get(url)
data_2004_soup = BeautifulSoup(data_2004.content, 'html.parser')
data_2004_soup
religion_part = data_2004_soup.find_all('tr')
for row_number in range(9,17):
    row = religion_part[row_number]
    tmp_string = ''
    table_header = row.find('th')
    table_values = row.find_all('td')
    tmp_string += table_header.text + ' '
    for tb in table_values:
        tmp_string += tb.text + ' '
    tmp_string = tmp_string[:-1].replace('\n','') + '\n'
    target.write(tmp_string)
target.close()
Explanation: Data Web Scraping: 2004
Download Source = https://www2.fbi.gov/ucr/hc2004/hctable1.htm
The data for 2004 is available as a HTML table on the website. 
Following steps are followed in data collection for 2004:
Request the content of the source page using python request libray.
Format the import webpage contect using python BeautifulSoup libray's 'html.parser'.
Since the relevant data is available in html table, loop through the relevant table rows, and extract the data values.
For each row, write the extracted data values into a local file, named 'source_2004.txt'
End of explanation
# Global Variables
all_years = [] # list of all the DataFrames.
sourcenames = ["source_"+str(year)+".txt" for year in range(1996,2005)] # list of source files names for 1996-2003, to be converted to .csv
targetnames = ["table1_"+str(year)+".csv" for year in range(1996,2005)] # List of name of all .csv files, to be imported in DataFrames
datanames = ["religion_"+str(year) for year in range(1996,2005)] # List of name of all dataframes, to be created e.g religion_1998,religion1999
'''
Steps for cleaing and converting the files to .csv format, 
and loading them in pandas DataFrames, using year 2003 as example:
'''
# Loop through the years 1996 to 2003 and repeat the same steps.
for i in range(9):
    
    source = sourcenames[i]
    target = targetnames[i]
    
    try:
        #Open the source file e.g source_2003
        source = open(source,"r",)
    except:
        print("Could not open the source file")
    else:
        # Open the target file e.g table1_2003.csv
        target = open(target, "w")
        lines = source.readlines();
        rows = len(lines)
        cols = 5
        
        # Loop through each line in the source file:
        for line in lines:
            # Remove the endline character i.e '\n'
            line = line.replace('\n','')
            # Remove all the commas ',' from the line.
            line = line.replace(",","")
            
            # Split the line into an array, using empty space as split character
            line_elements= line.split(' ')
            
            # Check if the number of array elements are greater than. If so, array[:-4] are part of the index in the table: join these elements into one element.
            if len(line_elements) > 5:
                # join the resulting elemets into a string using ',' as join character, and ending the string with newline character '\n'.
                new_line = " ".join(line_elements[:-4]) + ',' + ','.join(line_elements[-4:]) + '\n'
            else:
                # join the resulting elemets into a string using ',' as join character, and ending the string with newline character '\n'.
                new_line = ','.join(line_elements) + '\n'
            # write the resutling string to target file.
            target.write(new_line)
    
    # Close the target and source files.
    source.close()
    target.close()
    
    url = targetnames[i]
    
    # Use pandas_readcsv(filename) method to read the .csv file into DataFrames. Set DataFrame headers to ["Motivation","Incidents","Offenses","Victims","Known Offenders"]. Name the returned DataFrame as religion_2003.
    exec('%s = pd.read_csv(url, engine = "python", names = ["Motivation","Incidents","Offenses","Victims","Known Offenders"])' % (datanames[i]))
    
    # Save religion_2003 to all_years array of DataFrames.
    exec('all_years.append(%s)' % (datanames[i]))
# adding DataFrames for years 2005-2015 excluding 2009 into the all_years list
all_years.extend([religion_2005,religion_2006,religion_2007,religion_2008,religion_2010,religion_2011,religion_2012,religion_2013,religion_2014])
print('Variable dtypes:\n', religion_2000.dtypes, sep='')
religion_1996
rel = religion_1996['Motivation']
rel
Explanation: Data Import 1996 - 2004
Files for yeas 1995-2003, Table 1s are available within pdf reports, and will require a seperate importation technique as compared to the excel files. The relevant data is manually copied from each pdf file seperate, and stored into seperte local files.  
Steps for Data Collection using example of 2003:
The pdf data report is available on FBI's website.
Copy the relevant table rows representing the religion section from Table 1 in the report.
Paste the copied data into a local file named 'source_2003.txt'
Save the file.
Repeat the same steps for year 1996-2002 too.
Once the Data has been saved locally, it is cleaned and converted into .csv format, such that it can be directly imported into DataFrames afterwards.  
Steps for cleaing and converting the files to .csv format, and loading them in pandas DataFrames, using year 2003 as example:
Open the source file e.g source_2003
Open the target file e.g table1_2003.csv
Loop through each line in the source file:  
Remove the endline character i.e '\n'
Remove all the commas ',' from the line.
Split the line into an array, using empty space as split character.
Check if the number of array elements are greater than. If so, array[:-4] are part of the index in the table: join these elements into one element.
join the resulting elemets into a string using ',' as join character, and ending the string with newline character '\n'.
write the resutling string to target file.
Close the target and source files.
Use pandas_readcsv(filename) method to read the .csv file into DataFrames. Set DataFrame headers to ["Motivation","Incidents","Offenses","Victims","Known Offenders"]. Name the returned DataFrame as religion_2003.
Save religion_2003 to all_years array of DataFrames.
Loop through the years 1996 to 2003 and repeat the same steps.
End of explanation
religion_2003
Explanation: DataFrame Description for a particular year
Headers:
Motivation: The Motivation behind the hate crime. Anti-Islamic means hate crimes motivated by sentiment againsts Islam/Muslims(followers of Islam)
Incidents: Total Number of reported incidents of hate crimes, for a particular motivation
Offenses: Total Number of reported offenses of hate crimes, for a particular motivation 
Victims : Total Number of reported victims of hate crimes, for a particular motivation 
Known Offender: Total Number of reported known offenses of hate crimes, for a particular motivation
Indexes : Motivation (Following motivations have been recorded)
Religion: (Total Number for All Religions)
Anti-Jewish
Anti-Catholic
Anti-Protestant
Anti-Islamic
Anti-Other Religious Group (Total Number for Other religius groups)
Anti-Multi-Religious Group (Total Number for crimes which targetted multiple religions together)
Anti-Atheism/Agnosticism/etc.
Example for Year 2003 is shown below
End of explanation
#Variables and Description
# List of Indices (Motivation) in a DataFrame for a particular yaer
header_rows = ['All Religion','Anti-Jewish','Anti-Catholic','Anti-Protestants','Anti-Islamic','Anti-Other Religion','Anti-Multiple Religion,Group','Anti-Atheism/Agnosticism/etc.']
# List of headers in a DataFrame for particular yaer
columns = ['Incidents','Offenses', 'Victims','Known Offenders']
# List of headers for the new DataFrame
all_years_headers = []
#List of list of all values in the DataFrames for all years
all_years_list=[]
# List of the new indices, representing all reported years, for the new DataFrams.
all_years_keys = []
'''
Folloing Steps Are taken for Combining the Data:
'''
'''
Combine 8 Motivations with the different data values' headers:
    * Use the 8 motivations : ['All Religion','Anti-Jewish','Anti-Catholic','Anti-Protestants','Anti-Islamic','
    Anti-Other Religion','Anti-Multiple Religion,Group','Anti-Atheism/Agnosticism/etc.']
    * Use the 4 Data Values headers = ['Incidents','Offenses', 'Victims','Known Offenders']
    * Create 32 headers such that for each motivation, there are 4 different headers for the different data values.
    * E.g for 'Anti-Jewish' motivation, the resulting headers will be Anti-Jewish: Incidents,Anti-Jewish: Offenses,
    Anti-Jewish: Victims', and Anti-Jewish: Known Offenders.
    * all_years_headers is the list of all the generated headers.
'''
for row in header_rows:
    for col in columns:
        header_val = row + ': ' + str(col)
        all_years_headers.append(header_val)
'''
Generate a list called all_years_keys, which will correspond to the indices of the new DataFrame.
'''
for i in list(range(1996,2009)) + list(range(2010, 2015)):
    all_years_keys.append(str(i))
count = 0
'''
Create the combined DataFrame:
'''
# Loop through all_year - the list of the DataFrames representing each year            * 
for single_year in all_years:
    tmp_list =[]
    # Within each DataFrameLoop through all rows :
    for row in range(8):
        current_row = single_year.iloc[row]
        # Within each row, loop through all column values
        for col in columns:
            # add the column values into a temporary list
            tmp_list.append(current_row[col])
    # Add the temporary list cosisting of all the data values of the data frame into all_years_list.
    all_years_list.append(tmp_list)
    count+=1
'''
Create the DataFrame using all_years_list as data, all_years_keys as indices, all_years_headers as headers. 
Name this DataFrame hc, representing hate crimes 
'''
hc = pd.DataFrame(all_years_list, columns= all_years_headers, index = all_years_keys)
hc
Explanation: Combining DataFrames for all years into one DataFrame
all_years is the list of the DataFrames for all years.
We want to combine the data for all the years into one DataFrame so that it can be used for analysis.
Folloing Steps Are taken for Combining the Data:
Combine 8 Motivations with the different data values' headers:
Use the 8 motivations : ['All Religion','Anti-Jewish','Anti-Catholic','Anti-Protestants','Anti-Islamic','Anti-Other Religion','Anti-Multiple Religion,Group','Anti-Atheism/Agnosticism/etc.']
Use the 4 Data Values headers = ['Incidents','Offenses', 'Victims','Known Offenders']
Create 32 headers such that for each motivation, there are 4 different headers for the different data values.
E.g for 'Anti-Jewish' motivation, the resulting headers will be Anti-Jewish: Incidents,Anti-Jewish: Offenses,Anti-Jewish: Victims', and Anti-Jewish: Known Offenders.
all_years_headers is the list of all the generated headers.
Generate a list called all_years_keys, which will correspond to the indices of the new DataFrame.
    all_years_keys = ['1996',
 '1997',
 '1998',
 '1999',
 '2000',
 '2001',
 '2002',
 '2003',
 '2004',
 '2005',
 '2006',
 '2007',
 '2008',
 '2010',
 '2011',
 '2012',
 '2013',
 '2014']
Create the combined DataFrame:
Loop through all_year - the list of the DataFrames representing each year.
Within each DataFrameLoop through all rows within each DataFrame:
Within each row, loop through all column values
add the column values into a temporary list
Add the temporary list cosisting of all the data values of the data frame into all_years_list. all_years_list is the double-nested list of data values for all years.
Create the DataFrame using all_years_list as data, all_years_keys as indices, all_years_headers as headers. Name this DataFrame hc, representing hate crimes
End of explanation
anti_islam = hc['Anti-Islamic: Incidents']
anti_islam.plot(kind='line',
                grid = True,
                title = 'Anti-Islam Hate Crimes',
                sharey = True,
                sharex = True,
                use_index = True,
                legend = True,
                fontsize = 10 
                )
Explanation: Q: 1. How have the hate crimes against Muslims changed in terms of number of incidents per year?
End of explanation
print(anti_islam)
Explanation: Answer:
The number of hate crime incidents against Muslims have fluctuated a lot over the years. The most striking number of incidents took place in 2011 as shown by the graph above. Before 2011, the maximum number of incidents were 32, and the minimum were 211. In 2011, the number of incidents were 481. After 2011, the max number of incidents were 156, and the minimum were 105. In recent years, the hate crimes against Muslims have started to rise again.From 1995 to 2014, the number of incidents changed as shown below:
End of explanation
anti_islam_2011 = anti_islam[5]
anti_islam_2010 = anti_islam[4]
anti_islam_2012 = anti_islam[6]
percentage_change_2011 = (((anti_islam_2011 - anti_islam_2010)/anti_islam_2010)*100)
percentage_change_2012 = (((anti_islam_2012 - anti_islam_2011)/anti_islam_2011)*100)
print("Hate Crimes against Muslims growth in 2011 from 2010: ", percentage_change_2011, '%')
print("Hate Crimes against Muslims growth in 2010 from 2011: ", percentage_change_2012, '%')
anti_islam_before_2011 = anti_islam[:5].mean()
anti_islam_after_2011 = anti_islam[6:].mean()
print('Average hate crimes against Muslims before 2011: ', anti_islam_before_2011)
print('Average hate crimes against Muslims before 2011: ', anti_islam_after_2011)
avg = (((anti_islam_after_2011 - anti_islam_before_2011)/anti_islam_before_2011)*100)
print('Percentage increased in the average number of hate crimes against Muslims after 2011: ', avg)
Explanation: Q : Did September-11 Terrorist Attack had an impact on the hate crimes against Muslims? If so, how much impact did September-11 Terrorist Attack had?
End of explanation
anti_religion = hc['All Religion: Incidents']
anti_religion.plot(kind='line',
title = 'Hate Crimes Against All Religion',
sharey = True,
sharex = True,
use_index = True,
legend = True)
anti_religion_2011 = anti_religion[5]
anti_religion_2010 = anti_religion[4]
anti_religion_2012 = anti_religion[6]
avg_before_2011 = anti_religion[:5].mean()
avg_after_2011 = anti_religion[6:].mean() 
avg_after_2008 = anti_religion[13:].mean()
print('Average Number of Crimes before 2011 : ', avg_before_2011)
print('Avearage Number of Crimes after 2011 : ', avg_after_2011)
print('Avearage Number of Crimes after 2008 : ', avg_after_2008)
print('Hate Crimes in 2011 : ', anti_religion_2011)
Explanation: Answer:
September-11 Terrorist Attack had a huge impact on the number of hate-crimes against Muslims. The incident took place in 2011, where there were 481 hate crimes against Muslims, as opposed to 28 in 2010. The number of hate crimes against Muslims increased by more than 16 times (1672%) in 2011 as compared to 2010. In the following year (2012), the number of hate crimes against Muslims decreased by almost 68%. The average number of hate crimes against Muslims were 27 before 2011, and after 2011, they have increased to an average of 142. The average number of hate crimes against Muslims increased by more than 4 times (421%).
Q: How have the hate crimes against All religion changed in terms of number of incidents per year?
End of explanation
anti_muslim_percentage= (hc['Anti-Islamic: Incidents']/hc['All Religion: Incidents'])*100
anti_muslim_percentage.plot(kind = 'line',
                            title = 'Percentage of Hate Crimes Against Muslims Among All Religion',
                            sharey = True,
                            sharex = True,
                            use_index = True)
Explanation: Answer:
As shown in the graph above, the number of hate_crimes against all religion fluctuated by going up and down in between 1996 and 2008, with a very high peak in 2011. Since 2008, the number has seen a consistent and steady decrease. It is the same year, Barrack Obama got elected as the President of the United States. The average number of crimes before 2011 were 1412, and after 2011 they were 1288. In 2011, there were 1828, and most of the stark increase can be contributed towards the stark increase in the hate crimes against Muslims.
Q: What percentage of hate crimes motivated by religion identity target Muslims every year?
End of explanation
avg_before_2011 = something[:5].mean()
#not including 2011 in either average before or after 2011
avg_after_2011 = something[6:].mean()
perc_increase = (((avg_after_2011 - avg_before_2011)/avg_before_2011)*100)
print(avg_before_2011, avg_after_2011, perc_increase)
growth_list = []
Explanation: Answer
The ratio being discussed is shown above. Hate crimes targetting Muslims as a ratio of the hate-crimes motivated by religion has increased a lot in 2011 because of September-11 terrorist attack.Before, 2011, it was below 3% consistently, and in 2011 it went beyond 25%. After 2011, it never went down to its pre-2011 number. This also shows that the September-11 incident has increased the general sentiment against Muslims, and even after over a decade, the effect of September-11 on hate crimes against Muslims is clearly evident. Moreover, we can also see that the ratio has been rising in recent years showing that even though the number of hate-crimes against religions as a whole are decreasing, among those numbers, the ratio of attacks on Muslims in increaseing.
Q: On average what percentages of attacks motivated by religion targetted Muslims, before and after the September-11 Terrorist Attack?
End of explanation
<END_TASK>