-
Learn-Data-Science-the-Hard-Way
-
book
-
Python_for_Data_Analysis
Notebook
Out[7]:
[<matplotlib.lines.Line2D at 0x10f6fbc88>]
<matplotlib.figure.Figure at 0x10f749f60>
Out[13]:
[<matplotlib.lines.Line2D at 0x10f9071d0>]
Out[15]:
<matplotlib.collections.PathCollection at 0x10f907fd0>
Out[17]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x10f9f1b38>,
<matplotlib.axes._subplots.AxesSubplot object at 0x10fa3e860>,
<matplotlib.axes._subplots.AxesSubplot object at 0x10fa7b828>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x10fac4860>,
<matplotlib.axes._subplots.AxesSubplot object at 0x10fad4390>,
<matplotlib.axes._subplots.AxesSubplot object at 0x10fb55160>]], dtype=object)
Out[18]:
<matplotlib.axes._subplots.AxesSubplot at 0x10fa3e860>
Out[20]:
[<matplotlib.lines.Line2D at 0x1101b5518>]
Out[21]:
[<matplotlib.lines.Line2D at 0x1102a12e8>]
Out[22]:
[<matplotlib.lines.Line2D at 0x1103949b0>]
Out[23]:
[<matplotlib.lines.Line2D at 0x1104940f0>]
Out[25]:
[<matplotlib.lines.Line2D at 0x110586c88>]
Out[26]:
[<matplotlib.lines.Line2D at 0x110687940>]
/usr/local/lib/python3.5/site-packages/matplotlib/axes/_axes.py:519: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labelled objects found. "
Out[30]:
[<matplotlib.lines.Line2D at 0x1109fd1d0>]
Out[33]:
<matplotlib.text.Text at 0x11093c4e0>
Out[34]:
<matplotlib.text.Text at 0x1108cfa90>
Out[37]:
[<matplotlib.lines.Line2D at 0x110abfa90>]
Out[38]:
[<matplotlib.lines.Line2D at 0x110abfac8>]
Out[39]:
[<matplotlib.lines.Line2D at 0x110827cc0>]
Out[40]:
<matplotlib.legend.Legend at 0x110ac42e8>
ax.text(x, y, 'hello world!',
family = 'monospace', fontsize = 10)
Out[42]:
<matplotlib.text.Text at 0x111b1e8d0>
Out[43]:
<matplotlib.patches.Polygon at 0x111c606d8>
plt.savefig('figpath.svg')plt.savefig('figpath.png', dpi = 400, bbox_inches = 'tight')from io import StringIO
buffer = StringIO()
plt.savefig(buffer)
plot_data = buffer.getvalue()
font_options = {'family': 'monospace',
'weight': 'bold',
'size': 'small'}
plt.rc('font', **font_options)
Out[47]:
<matplotlib.axes._subplots.AxesSubplot at 0x110bc7e10>
Out[49]:
<matplotlib.axes._subplots.AxesSubplot at 0x111ca2400>
Out[52]:
<matplotlib.axes._subplots.AxesSubplot at 0x111cd8da0>
Out[53]:
<matplotlib.axes._subplots.AxesSubplot at 0x111cd8da0>
Out[55]:
<matplotlib.axes._subplots.AxesSubplot at 0x11001a390>
Out[56]:
<matplotlib.axes._subplots.AxesSubplot at 0x11003fdd8>
Out[57]:
<matplotlib.axes._subplots.AxesSubplot at 0x111d4de48>
Out[62]:
|
total_bill |
tip |
sex |
smoker |
day |
time |
size |
0 |
16.99 |
1.01 |
Female |
No |
Sun |
Dinner |
2 |
1 |
10.34 |
1.66 |
Male |
No |
Sun |
Dinner |
3 |
2 |
21.01 |
3.50 |
Male |
No |
Sun |
Dinner |
3 |
3 |
23.68 |
3.31 |
Male |
No |
Sun |
Dinner |
2 |
4 |
24.59 |
3.61 |
Female |
No |
Sun |
Dinner |
4 |
Out[63]:
col_0 |
1708 |
day |
|
Fri |
19 |
Sat |
87 |
Sun |
76 |
Thur |
62 |
Out[64]:
col_0 |
day |
Fri |
Sat |
Sun |
Thur |
Out[24]:
size |
2 |
3 |
4 |
5 |
day |
|
|
|
|
Fri |
0.888889 |
0.055556 |
0.055556 |
0.000000 |
Sat |
0.623529 |
0.211765 |
0.152941 |
0.011765 |
Sun |
0.520000 |
0.200000 |
0.240000 |
0.040000 |
Thur |
0.827586 |
0.068966 |
0.086207 |
0.017241 |
4 rows × 4 columns
Out[25]:
<matplotlib.axes.AxesSubplot at 0x7fab064c0f50>
Out[67]:
|
total_bill |
tip |
sex |
smoker |
day |
time |
size |
0 |
16.99 |
1.01 |
Female |
No |
Sun |
Dinner |
2 |
1 |
10.34 |
1.66 |
Male |
No |
Sun |
Dinner |
3 |
2 |
21.01 |
3.50 |
Male |
No |
Sun |
Dinner |
3 |
3 |
23.68 |
3.31 |
Male |
No |
Sun |
Dinner |
2 |
4 |
24.59 |
3.61 |
Female |
No |
Sun |
Dinner |
4 |
Out[72]:
<matplotlib.axes._subplots.AxesSubplot at 0x10fda7f28>
Out[73]:
<matplotlib.axes._subplots.AxesSubplot at 0x110026978>
Out[76]:
<matplotlib.axes._subplots.AxesSubplot at 0x1138dddd8>
Out[77]:
<matplotlib.axes._subplots.AxesSubplot at 0x1152a36a0>
Out[78]:
|
year |
quarter |
realgdp |
realcons |
realinv |
realgovt |
realdpi |
cpi |
m1 |
tbilrate |
unemp |
pop |
infl |
realint |
0 |
1959.0 |
1.0 |
2710.349 |
1707.4 |
286.898 |
470.045 |
1886.9 |
28.98 |
139.7 |
2.82 |
5.8 |
177.146 |
0.00 |
0.00 |
1 |
1959.0 |
2.0 |
2778.801 |
1733.7 |
310.859 |
481.301 |
1919.7 |
29.15 |
141.7 |
3.08 |
5.1 |
177.830 |
2.34 |
0.74 |
2 |
1959.0 |
3.0 |
2775.488 |
1751.8 |
289.226 |
491.260 |
1916.4 |
29.35 |
140.5 |
3.82 |
5.3 |
178.657 |
2.74 |
1.09 |
3 |
1959.0 |
4.0 |
2785.204 |
1753.7 |
299.356 |
484.052 |
1931.3 |
29.37 |
140.0 |
4.33 |
5.6 |
179.386 |
0.27 |
4.06 |
4 |
1960.0 |
1.0 |
2847.699 |
1770.5 |
331.722 |
462.199 |
1955.5 |
29.54 |
139.6 |
3.50 |
5.2 |
180.007 |
2.31 |
1.19 |
Out[81]:
|
cpi |
m1 |
tbilrate |
unemp |
1 |
0.005849 |
0.014215 |
0.088193 |
-0.128617 |
2 |
0.006838 |
-0.008505 |
0.215321 |
0.038466 |
3 |
0.000681 |
-0.003565 |
0.125317 |
0.055060 |
4 |
0.005772 |
-0.002861 |
-0.212805 |
-0.074108 |
5 |
0.000338 |
0.004289 |
-0.266946 |
0.000000 |
Out[84]:
<matplotlib.text.Text at 0x1132f7898>
Out[85]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x1132fa630>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115c99f60>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115ce8a58>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115d24400>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x115d6d438>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115dadbe0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115dfe320>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115e32a20>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x115e81c50>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115ecc9b0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115f11eb8>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115f61048>],
[<matplotlib.axes._subplots.AxesSubplot object at 0x115f9c2b0>,
<matplotlib.axes._subplots.AxesSubplot object at 0x115fe6d68>,
<matplotlib.axes._subplots.AxesSubplot object at 0x116022550>,
<matplotlib.axes._subplots.AxesSubplot object at 0x11606fcc0>]], dtype=object)
Out[87]:
|
Serial |
INCIDENT TITLE |
INCIDENT DATE |
LOCATION |
DESCRIPTION |
CATEGORY |
LATITUDE |
LONGITUDE |
APPROVED |
VERIFIED |
0 |
4052 |
* URGENT * Type O blood donations needed in #J... |
05/07/2010 17:26 |
Jacmel, Haiti |
Birthing Clinic in Jacmel #Haiti urgently need... |
1. Urgences | Emergency, 3. Public Health, |
18.233333 |
-72.533333 |
YES |
NO |
1 |
4051 |
Food-Aid sent to Fondwa, Haiti |
28/06/2010 23:06 |
fondwa |
Please help food-aid.org deliver more food to ... |
1. Urgences | Emergency, 2. Urgences logistiqu... |
50.226029 |
5.729886 |
NO |
NO |
2 |
4050 |
how haiti is right now and how it was during t... |
24/06/2010 16:21 |
centrie |
i feel so bad for you i know i am supposed to ... |
2. Urgences logistiques | Vital Lines, 8. Autr... |
22.278381 |
114.174287 |
NO |
NO |
3 |
4049 |
Lost person |
20/06/2010 21:59 |
Genoca |
We are family members of Juan Antonio Zuniga O... |
1. Urgences | Emergency, |
44.407062 |
8.933989 |
NO |
NO |
4 |
4042 |
Citi Soleil school |
18/05/2010 16:26 |
Citi Soleil, Haiti |
We are working with Haitian (NGO) -The Christi... |
1. Urgences | Emergency, |
18.571084 |
-72.334671 |
YES |
NO |
Out[88]:
|
INCIDENT DATE |
LATITUDE |
LONGITUDE |
0 |
05/07/2010 17:26 |
18.233333 |
-72.533333 |
1 |
28/06/2010 23:06 |
50.226029 |
5.729886 |
2 |
24/06/2010 16:21 |
22.278381 |
114.174287 |
3 |
20/06/2010 21:59 |
44.407062 |
8.933989 |
4 |
18/05/2010 16:26 |
18.571084 |
-72.334671 |
5 |
26/04/2010 13:14 |
18.593707 |
-72.310079 |
6 |
26/04/2010 14:19 |
18.482800 |
-73.638800 |
7 |
26/04/2010 14:27 |
18.415000 |
-73.195000 |
8 |
15/03/2010 10:58 |
18.517443 |
-72.236841 |
9 |
15/03/2010 11:00 |
18.547790 |
-72.410010 |
Out[89]:
0 1. Urgences | Emergency, 3. Public Health,
1 1. Urgences | Emergency, 2. Urgences logistiqu...
2 2. Urgences logistiques | Vital Lines, 8. Autr...
3 1. Urgences | Emergency,
4 1. Urgences | Emergency,
5 5e. Communication lines down,
Name: CATEGORY, dtype: object
Out[90]:
|
Serial |
LATITUDE |
LONGITUDE |
count |
3593.000000 |
3593.000000 |
3593.000000 |
mean |
2080.277484 |
18.611495 |
-72.322680 |
std |
1171.100360 |
0.738572 |
3.650776 |
min |
4.000000 |
18.041313 |
-74.452757 |
25% |
1074.000000 |
18.524070 |
-72.417500 |
50% |
2163.000000 |
18.539269 |
-72.335000 |
75% |
3088.000000 |
18.561820 |
-72.293570 |
max |
4052.000000 |
50.226029 |
114.174287 |
Out[110]:
'Earthquake and aftershocks'
Out[116]:
|
1 |
2 |
3 |
4 |
5 |
6 |
0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
4 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
5 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
6 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
0.0 |
Out[120]:
|
Serial |
INCIDENT TITLE |
INCIDENT DATE |
LOCATION |
DESCRIPTION |
0 |
4052 |
* URGENT * Type O blood donations needed in #J... |
05/07/2010 17:26 |
Jacmel, Haiti |
Birthing Clinic in Jacmel #Haiti urgently need... |
4 |
4042 |
Citi Soleil school |
18/05/2010 16:26 |
Citi Soleil, Haiti |
We are working with Haitian (NGO) -The Christi... |
5 |
4041 |
Radio Commerce in Sarthe |
26/04/2010 13:14 |
Radio Commerce Shelter, Sarthe |
i'm Louinel from Sarthe. I'd to know what can ... |
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
def basic_haiti_map(ax=None, lllat=17.25, urlat=20.25, lllon=-75, urlon=-71):
# create polar stereographic Basemap instance.
m = Basemap(ax=ax, projection='stere',
lon_0=(urlon + lllon) / 2,
lat_0=(urlat + lllat) / 2,
llcrnrlat=lllat,
urcrnrlat=urlat,
llcrnrlon=lllon,
urcrnrlon=urlon,
resolution='f')
# draw coastlines, state and country boundaries, edge of map.
m.drawcoastlines()
m.drawstates()
m.drawcountries()
return m