In [1]:
import cufflinks as cf
import numpy as np
import pandas as pd
from plotly.offline import init_notebook_mode, plot, iplot
import plotly.graph_objs as go

In [2]:
init_notebook_mode(connected=False)
cf.go_offline()



In [3]:
df = pd.read_csv('../data/midwest.csv')

In [4]:
df.describe()


Out[4]:
Unnamed: 0 PID area poptotal popdensity popwhite popblack popamerindian popasian popother ... perchsd percollege percprof poppovertyknown percpovertyknown percbelowpoverty percchildbelowpovert percadultpoverty percelderlypoverty inmetro
count 437.000000 437.000000 437.000000 4.370000e+02 437.000000 4.370000e+02 4.370000e+02 437.000000 437.000000 437.000000 ... 437.000000 437.000000 437.000000 4.370000e+02 437.000000 437.000000 437.000000 437.000000 437.000000 437.000000
mean 219.000000 1437.338673 0.033169 9.613030e+04 3097.742985 8.183992e+04 1.102388e+04 343.109840 1310.464531 1612.931350 ... 73.965546 18.272736 4.447259 9.364228e+04 97.110267 12.510505 16.447464 10.918798 11.389043 0.343249
std 126.295289 876.390266 0.014679 2.981705e+05 7664.751786 2.001966e+05 7.895827e+04 868.926751 9518.394189 18526.540699 ... 5.843177 6.261908 2.408427 2.932351e+05 2.749863 5.150155 7.228634 5.109166 3.661259 0.475338
min 1.000000 561.000000 0.005000 1.701000e+03 85.050000 4.160000e+02 0.000000e+00 4.000000 0.000000 0.000000 ... 46.912261 7.336108 0.520291 1.696000e+03 80.902441 2.180168 1.918955 1.938504 3.547067 0.000000
25% 110.000000 670.000000 0.024000 1.884000e+04 622.407407 1.863000e+04 2.900000e+01 44.000000 35.000000 20.000000 ... 71.325329 14.113725 2.997957 1.836400e+04 96.894572 9.198715 11.624088 7.668009 8.911763 0.000000
50% 219.000000 1221.000000 0.030000 3.532400e+04 1156.208330 3.447100e+04 2.010000e+02 94.000000 102.000000 66.000000 ... 74.246891 16.797562 3.814239 3.378800e+04 98.169562 11.822313 15.270164 10.007610 10.869119 0.000000
75% 328.000000 2059.000000 0.038000 7.565100e+04 2330.000000 7.296800e+04 1.291000e+03 288.000000 401.000000 345.000000 ... 77.195344 20.549893 4.949324 7.284000e+04 98.598636 15.133226 20.351878 13.182182 13.412162 1.000000
max 437.000000 3052.000000 0.110000 5.105067e+06 88018.396600 3.204947e+06 1.317147e+06 10289.000000 188565.000000 384119.000000 ... 88.898674 48.078510 20.791321 5.023523e+06 99.860384 48.691099 64.308477 43.312464 31.161972 1.000000

8 rows × 26 columns


In [5]:
sub = df[['poptotal', 'percollege']].dropna()[:10]

In [6]:
sub.iplot(filename='jupyter/percollege', sharing='private')


cufflinks helps a good bit by having that iplot method. Note that it is different from the plotly iplot function, as shown below:


In [7]:
N = 500
x = np.linspace(0, 1, N)
y = np.random.randn(N)
df2 = pd.DataFrame({'x': x, 'y': y})
df2.head()


Out[7]:
x y
0 0.000000 -0.303962
1 0.002004 0.611165
2 0.004008 1.812388
3 0.006012 -0.599898
4 0.008016 0.333871

In [8]:
data2 = [go.Histogram(y=df2['y'])]

In [9]:
iplot(data2)



In [ ]: