In [1]:
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
In [2]:
data = pd.read_csv(r'D:\Anaconda Files\Earthquakes\Earthquakes.csv', decimal=',' ,sep='\t', encoding='utf-8')
data['Date'] = pd.to_datetime(data['Date'])
data['Magnitude'] = data['Magnitude'].astype(float)
In [3]:
 
Out[3]:
<matplotlib.axes._subplots.AxesSubplot at 0x29e13633c08>
In [4]:
#sns.set_theme(style="whitegrid")

#tips = sns.load_dataset("tips")
plt.figure(figsize=(20,6))
ax = sns.boxplot(x=data["Magnitude"])
In [25]:
#Plot Histogram of "size"
plt.figure(figsize=(20,6))
sns.distplot(data["Magnitude"], bins = 40)
Out[25]:
<matplotlib.axes._subplots.AxesSubplot at 0x29e126af048>
In [19]:
#Plot Histogram of "size"

datax = data[data['Magnitude'] >= 7]
plt.figure(figsize=(20,6))
sns.distplot(datax["Magnitude"], bins = 26)
Out[19]:
<matplotlib.axes._subplots.AxesSubplot at 0x29e1211bc48>
In [6]:
#Count
rank_pre = data.groupby(['Country'])['Country'].count()
rank_pre = pd.DataFrame(rank_pre, columns=['Country', 'Length'])
rank_pre = rank_pre.drop(rank_pre.columns[1],axis=1)
rank_pre.index.names = ['Country_Name']
rank_pre.rename(columns = {'Country':'Count >5'}, inplace = True)

rank_pre.sort_values(by=['Count >5'], inplace=True, ascending=False)
In [7]:
rank_pre.head(15)
Out[7]:
Count >5
Country_Name
Indonesia 9538
Papua New Guinea 5369
Russia 5083
Japan 5050
Philippines 4419
Alaska 4111
Tonga 3351
Vanuatu 2777
Chile 2414
Solomon Islands 1932
China 1533
Mexico 1427
New Zealand 1404
Peru 1346
Japan region 1231
In [8]:
data_pre = data[data['Magnitude'] >= 6]
rank_pre = data_pre.groupby(['Country'])['Country'].count()
rank_pre = pd.DataFrame(rank_pre, columns=['Country', 'Length'])
rank_pre = rank_pre.drop(rank_pre.columns[1],axis=1)
rank_pre.index.names = ['Country_Name']
rank_pre.rename(columns = {'Country':'Count >6'}, inplace = True)

rank_pre.sort_values(by=['Count >6'], inplace=True, ascending=False)
In [9]:
rank_pre.head(15)
Out[9]:
Count >6
Country_Name
Indonesia 1096
Papua New Guinea 721
Japan 712
Russia 696
Alaska 646
Philippines 548
Tonga 354
Vanuatu 305
Chile 294
Mexico 261
China 259
Solomon Islands 241
California 239
Greece 162
New Zealand 160
In [10]:
data_pre = data[data['Magnitude'] >= 7]
rank_pre = data_pre.groupby(['Country'])['Country'].count()
rank_pre = pd.DataFrame(rank_pre, columns=['Country', 'Length'])
rank_pre = rank_pre.drop(rank_pre.columns[1],axis=1)
rank_pre.index.names = ['Country_Name']
rank_pre.rename(columns = {'Country':'Count >7'}, inplace = True)

rank_pre.sort_values(by=['Count >7'], inplace=True, ascending=False)
In [11]:
rank_pre.head(15)
Out[11]:
Count >7
Country_Name
Indonesia 124
Alaska 102
Japan 87
Papua New Guinea 85
Russia 78
Philippines 70
Chile 45
Mexico 45
Tonga 44
California 42
Solomon Islands 36
China 34
Vanuatu 33
Peru 16
Turkey 15
In [ ]:
 
In [64]:
 
In [20]:
#Count
rank_pre = data.groupby(['Magnitude'])['Magnitude'].count()
In [22]:
rank_pre.head(20)
Out[22]:
Magnitude
5.00    17006
5.01        4
5.02        7
5.03       10
5.04        6
5.05        3
5.06       13
5.07        4
5.08        7
5.09        7
5.10    13474
5.11        1
5.12        4
5.13        3
5.14        4
5.15        4
5.16        1
5.17        5
5.18        9
5.19       10
Name: Magnitude, dtype: int64
In [ ]: