Data¶
In [2]:
earth_quake = pd.read_csv("earthquake.csv")
In [3]:
earth_quake.head()
Out[3]:
In [4]:
earth_quake.columns
Out[4]:
In [5]:
earth = earth_quake[["Date","Latitude","Longitude","Magnitude"]]
In [6]:
earth.head()
Out[6]:
In [7]:
earth.tail()
Out[7]:
In [8]:
earth["Date"] = pd.to_datetime(earth["Date"])
In [9]:
earth.shape
Out[9]:
Creating a Basemap instance¶
In [10]:
m = Basemap(projection="mill")
Converting from spherical to cartesian coordinates¶
In [11]:
longitudes = earth["Longitude"].tolist()
latitudes = earth["Latitude"].tolist()
x,y = m(longitudes,latitudes)
Generating a Scatter Plot¶
In [12]:
fig = plt.figure(figsize=(12,10))
plt.title("All affected areas")
m.scatter(x,y, s = 4, c = "blue")
m.drawcoastlines()
m.fillcontinents(color='coral',lake_color='aqua')
m.drawmapboundary()
m.drawcountries()
plt.show()
The Severity of an Earthquake¶
Minimum and Maximum Magnitude¶
In [13]:
minimum = earth["Magnitude"].min()
maximum = earth["Magnitude"].max()
average = earth["Magnitude"].mean()
print("Minimum:", minimum)
print("Maximum:",maximum)
print("Mean",average)
In [14]:
(n,bins, patches) = plt.hist(earth["Magnitude"], range=(0,10), bins=10)
plt.xlabel("Earthquake Magnitudes")
plt.ylabel("Number of Occurences")
plt.title("Overview of earthquake magnitudes")
print("Magnitude" +" "+ "Number of Occurence")
for i in range(5, len(n)):
print(str(i)+ "-"+str(i+1)+" " +str(n[i]))
- Over 16,000 (68.5%) earthquakes magnitude were between 5 and 6
- Over 40 (0.17%) earthquakes magitude were greater than 8.
In [15]:
plt.boxplot(earth["Magnitude"])
plt.show()
In [16]:
highly_affected = earth[earth["Magnitude"]>=8]
In [17]:
print(highly_affected.shape)
In [18]:
longitudes = highly_affected["Longitude"].tolist()
latitudes = highly_affected["Latitude"].tolist()
x,y = m(longitudes,latitudes)
fig = plt.figure(figsize=(12,10))
plt.title("Highly affected areas affected areas")
m.scatter(x,y, c = "blue", s = highly_affected["Magnitude"] *20)
m.drawcoastlines()
m.fillcontinents(color='coral',lake_color='aqua')
m.drawmapboundary()
m.drawcountries()
plt.show()