<jupyter_start><jupyter_text>Intrudction : Our data is about people's mindset behind the occurrence of Earthquakes in cities and towns.  First, let's see the data :<jupyter_code>data_set = pd.read_csv('earthquake_data.csv') 
data_set.head()
### Organize the data
- Treat missing values.
- removing all the columns that are not rellevant to our research.<jupyter_output><empty_output><jupyter_text>Let's check our NuN values :<jupyter_code>data_set.isnull().sum()<jupyter_output><empty_output><jupyter_text>Our data have 1013 rows, and we dont have a lot of NuN values, so we remove them.<jupyter_code>data_set = data_set.dropna()<jupyter_output><empty_output><jupyter_text>There are few columns that we didn't rely on when we analyzed our data. In the following code, we removing them.<jupyter_code>data_set = data_set.loc[:,['In general, how worried are you about earthquakes?','How worried are you about the Big One, a massive, catastrophic earthquake?','Have you ever experienced an earthquake?','Age','How much total combined money did all members of your HOUSEHOLD earn last year?','US Region']]
data_set.head()<jupyter_output><empty_output><jupyter_text>Now that we orginized the data, Let's analysis :   We wanted to see if there was a connection between the two questions 'In general, how worried are you about earthquakes?' and 'How worried are you about the Big One, a massive, catastrophic earthquake?'<jupyter_code>plt.figure(figsize=(20,15))
plt.subplot(2,2,1)
sns.countplot(x= 'In general, how worried are you about earthquakes?', data = data_set, order = data_set['In general, how worried are you about earthquakes?'].value_counts().index)
plt.subplot(2,2,2)
sns.countplot(x= 'How worried are you about the Big One, a massive, catastrophic earthquake?', data = data_set, order = data_set['How worried are you about the Big One, a massive, catastrophic earthquake?'].value_counts().index)<jupyter_output><empty_output><jupyter_text>The following charts displays the connection between the two levels/kinds of fear. According to that connection , from now on we will use mostly the "fear in general" question.  YALLA lets start :   1. The first thing that we'll going to analysis is if the age is affecting the fear of earthquakes :    first we used "get_dummies" and "groupby" functions to split that "Age" Values to binary column, and to group by them.<jupyter_code>x_data = pd.get_dummies(data=data_set, columns=['Age'])
x_data = x_data.groupby('In general, how worried are you about earthquakes?')[['Age_18 - 29','Age_30 - 44','Age_45 - 59','Age_60']].sum()<jupyter_output><empty_output><jupyter_text>Here we made some pie charts for us to analysis :<jupyter_code>plt.figure(figsize=(15,11))
explode = (0.1, 0, 0, 0, 0.1)
plt.subplot(2,2,1)
plt.title("Age : 18 - 29",bbox={'facecolor':'0.8', 'pad':7})
x_data['Age_18 - 29'].plot.pie(autopct='%1.1f%%',explode = explode)
plt.subplot(2,2,2)
plt.title("Age : 30 - 44",bbox={'facecolor':'0.8', 'pad':7})
x_data['Age_30 - 44'].plot.pie(autopct='%1.1f%%',explode = explode)
plt.subplot(2,2,3)
plt.title("Age : 45 - 59",bbox={'facecolor':'0.8', 'pad':7})
x_data['Age_45 - 59'].plot.pie(autopct='%1.1f%%',explode = explode)
plt.subplot(2,2,4)
plt.title("Age : 60+",bbox={'facecolor':'0.8', 'pad':7})
x_data['Age_60'].plot.pie(autopct='%1.1f%%',explode = explode)<jupyter_output><empty_output><jupyter_text>In conclusion :  We can see the age does matter, the older you are, the fearless of earthqueakes you become!   - US regions map.<jupyter_code>from IPython.display import Image
from IPython.core.display import HTML 
Image(url= "https://united-states.reaproject.org/img/maps/Census_Divisions_Full.png",width=600, height=600)
#https://united-states.reaproject.org/<jupyter_output><empty_output><jupyter_text>2. Let's see if there is a connection between the fear and regions :<jupyter_code>plt.figure(figsize = (15, 8))
sns.countplot(x="US Region", hue='In general, how worried are you about earthquakes?', data=data_set, palette="rainbow_r", hue_order= ['Extremely worried','Very worried','Somewhat worried','Not so worried','Not at all worried'])<jupyter_output><empty_output><jupyter_text>We can see the fear in the pacific is the highest, why?   Let's see if other columns can give us information about the pacific compare to the other regions. The following chart is the amount of expirence with earthquakes in each region :<jupyter_code>plt.figure(figsize = (15, 8))
sns.countplot(x="US Region", hue="Have you ever experienced an earthquake?", data=data_set, palette="rainbow_r",hue_order = ['Yes, one or more major ones','Yes, one or more minor ones','No'])<jupyter_output><empty_output><jupyter_text>The conclosion is clear!  In places that expirenced more earthquakes, there is more people that fear from them.  - The pacific sounds quite terrifing for earthquakes, let's have a little look at USA earthquakes hot spots:<jupyter_code>from IPython.display import Image
from IPython.core.display import HTML 
Image(url="https://www.sciencemag.org/sites/default/files/styles/article_main_large/public/images/sn-seismicH.jpg?itok=ft_cAqGT",width=700, height=700)<jupyter_output><empty_output><jupyter_text>If people are afraid in the pacific, and experienced earthquakes in the pacific, what makes them stay?   3.the question makes us wonder, is it about the money? like everthing else?    Counting the people household earnings :<jupyter_code>data_set['People_index']=  data_set.index
data_set.groupby('How much total combined money did all members of your HOUSEHOLD earn last year?')[['People_index']].count()<jupyter_output><empty_output><jupyter_text>The "Prefer not to answer" value can be problematic, so we decided to remove them :<jupyter_code>wanted_val= data_set[data_set['How much total combined money did all members of your HOUSEHOLD earn last year?']=="Prefer not to answer"].index
data_set.drop(wanted_val, inplace=True)
data_set.groupby('How much total combined money did all members of your HOUSEHOLD earn last year?')[['People_index']].count()<jupyter_output><empty_output><jupyter_text>We can change the values to categories so we can use them more easily :<jupyter_code>data_set['How much total combined money did all members of your HOUSEHOLD earn last year?'] = data_set['How much total combined money did all members of your HOUSEHOLD earn last year?'].astype('category').cat.codes
data_set.groupby('How much total combined money did all members of your HOUSEHOLD earn last year?')[['People_index']].count()<jupyter_output><empty_output><jupyter_text>Editing the order of the categories values :<jupyter_code>change_values = {0:1,1:2,2:6,3:7,4:8,5:9,6:10,7:3,8:4,9:5}
data_set['How much total combined money did all members of your HOUSEHOLD earn last year?'].replace(change_values, inplace=True)<jupyter_output><empty_output><jupyter_text>Finally we can show the boxplot we wanted :<jupyter_code>plt.figure(figsize=(15,10))
sns.boxplot(x = 'US Region', y = 'How much total combined money did all members of your HOUSEHOLD earn last year?', data = data_set, palette="gist_ncar_r", whis =2)
plt.xlabel("Regions", size=16)
plt.ylabel("Household earnings", size=16)
plt.title("Household earnings VS regions", size=24)
plt.ylim(0, 11,10)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12119123121466979, 'fraction_numerical': 0.021646215359161725, 'mean_word_length': 6.684322033898305, 'pattern_counts': {'":': 0, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 3, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '475560', 'license': 'CC0-1.0', 'n_tokens_mistral': 2525, 'n_tokens_neox': 2356, 'n_words': 739, 'path': 'projects-spring-2021/T.ipynb', 'repo_name': 'YuLe33/data-analytics', 'size': '7253'}