In [1]:
# Numeric Packages
from __future__ import division
import numpy as np
import pandas as pd
import scipy.stats as sps

# Plotting packages
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
sns.set_style('whitegrid')

# Other
from datetime import datetime, timedelta
import statsmodels.api as sm

In [2]:
# Import turnstile data and convert datetime column to datetime python objects
df = pd.read_csv('turnstile_weather_v2.csv')
df['datetime'] = pd.to_datetime(df['datetime'])

In [3]:
# Because the hour '0' is actually the entries from 20:00 to 24:00, it makes more sense to label it 24 when plotting data
df.datetime -= timedelta(seconds=1)
df['day']= df.datetime.apply(lambda x: x.day)
df['hour'] = df.datetime.apply(lambda x: x.hour+1)
df['weekday'] = df.datetime.apply(lambda x: not bool(x.weekday()//5))
df['day_week'] = df.datetime.apply(lambda x: x.weekday())
# df.loc[df['hour']==24, 'day'] -=1

In [4]:
# The dataset includes the Memorial Day Public Holiday, which should be classified as a weekend.
df.loc[df['day']==30,'weekday'] = False

In [5]:
# Filter out results from 30th April... they're just going to make things messy in the plots
plot_df = df[df.datetime.apply(lambda x: x.month==5)]

In [6]:
timelabels = ['Midnight - 4am','4am - 8am','8am - 12pm','12pm - 4pm','4pm - 8pm','8pm - Midnight']
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']

In [7]:
plt.figure(figsize=[20,6])

plt.subplot(211)
data=df.pivot_table(values='ENTRIESn_hourly',index='hour',columns='day', aggfunc=np.sum)
sns.heatmap(data, cmap='YlGnBu', yticklabels=timelabels)
plt.ylabel('')
plt.xlabel('')
plt.xlim(0,32)
plt.title('Daily NYC Subway Ridership (top) and Precipitation (bottom) for May 2011', fontsize=16)
# plt.show()


plt.subplot(212)
data=df.pivot_table(values='precipi',index='hour',columns='day', aggfunc=np.mean)
# plt.figure(figsize=[20,3])
sns.heatmap(data, cmap='OrRd', yticklabels=timelabels)
plt.ylabel('')
plt.xlim(0,32)
plt.xticks([])
# plt.title('Daily NYC Subway Ridership for May 2011', fontsize=16)
plt.show()



In [8]:
mydf = df[df.day!=30].pivot_table(values='ENTRIESn_hourly', index=['day','day_week','hour'], aggfunc=np.sum).reset_index()
mydf = mydf.pivot_table(values='ENTRIESn_hourly', index='hour', columns='day_week', aggfunc=np.mean)


sns.heatmap(mydf, yticklabels=timelabels, xticklabels=weekdays)
plt.xlabel('')
plt.ylabel('')
plt.title('Daily NYC Subway Ridership for May 2011', fontsize=14)
plt.show()

In [10]:
df.columns


Out[10]:
Index([u'UNIT', u'DATEn', u'TIMEn', u'ENTRIESn', u'EXITSn', u'ENTRIESn_hourly',
       u'EXITSn_hourly', u'datetime', u'hour', u'day_week', u'weekday',
       u'station', u'latitude', u'longitude', u'conds', u'fog', u'precipi',
       u'pressurei', u'rain', u'tempi', u'wspdi', u'meanprecipi',
       u'meanpressurei', u'meantempi', u'meanwspdi', u'weather_lat',
       u'weather_lon', u'day'],
      dtype='object')

In [11]:
df['hour_str'] = [str(i) for i in df['hour']]
df['day_str'] = df.datetime.apply(lambda x: x.strftime('%A'))

In [60]:
mod = sm.OLS.from_formula('ENTRIESn_hourly ~ precipi + C(weekday) + UNIT + C(hour) -1', data=df)
res = mod.fit()
print res.summary()


                            OLS Regression Results                            
==============================================================================
Dep. Variable:        ENTRIESn_hourly   R-squared:                       0.552
Model:                            OLS   Adj. R-squared:                  0.549
Method:                 Least Squares   F-statistic:                     212.0
Date:                Sat, 01 Aug 2015   Prob (F-statistic):               0.00
Time:                        00:06:18   Log-Likelihood:            -3.8420e+05
No. Observations:               42649   AIC:                         7.689e+05
Df Residuals:                   42402   BIC:                         7.710e+05
Df Model:                         246                                         
Covariance Type:            nonrobust                                         
=====================================================================================
                        coef    std err          t      P>|t|      [95.0% Conf. Int.]
-------------------------------------------------------------------------------------
C(weekday)[False] -2184.8212    155.032    -14.093      0.000     -2488.686 -1880.956
C(weekday)[True]  -1006.7314    154.529     -6.515      0.000     -1309.611  -703.852
UNIT[T.R004]        369.3355    214.183      1.724      0.085       -50.467   789.138
UNIT[T.R005]        354.7416    215.095      1.649      0.099       -66.848   776.331
UNIT[T.R006]        540.9419    212.731      2.543      0.011       123.986   957.898
UNIT[T.R007]        175.5685    215.718      0.814      0.416      -247.244   598.381
UNIT[T.R008]        169.7682    216.036      0.786      0.432      -253.666   593.202
UNIT[T.R009]        168.8228    214.184      0.788      0.431      -250.981   588.627
UNIT[T.R011]       7247.1623    211.615     34.247      0.000      6832.392  7661.933
UNIT[T.R012]       8602.4316    211.074     40.756      0.000      8188.722  9016.141
UNIT[T.R013]       2500.8725    211.074     11.848      0.000      2087.163  2914.582
UNIT[T.R016]        677.4340    211.615      3.201      0.001       262.664  1092.204
UNIT[T.R017]       4115.8671    211.074     19.500      0.000      3702.158  4529.577
UNIT[T.R018]       7694.1850    211.336     36.407      0.000      7279.962  8108.408
UNIT[T.R019]       3165.3689    211.067     14.997      0.000      2751.673  3579.065
UNIT[T.R020]       6291.9639    211.074     29.809      0.000      5878.254  6705.673
UNIT[T.R021]       4602.5269    211.616     21.749      0.000      4187.756  5017.298
UNIT[T.R022]       9436.3564    211.074     44.706      0.000      9022.647  9850.066
UNIT[T.R023]       6071.5338    211.074     28.765      0.000      5657.824  6485.243
UNIT[T.R024]       3127.1540    211.337     14.797      0.000      2712.930  3541.378
UNIT[T.R025]       5262.2614    211.067     24.932      0.000      4848.565  5675.958
UNIT[T.R027]       2885.9693    211.074     13.673      0.000      2472.260  3299.679
UNIT[T.R029]       7147.9424    211.074     33.865      0.000      6734.233  7561.652
UNIT[T.R030]       3018.1359    211.074     14.299      0.000      2604.427  3431.845
UNIT[T.R031]       4269.9047    211.074     20.229      0.000      3856.195  4683.614
UNIT[T.R032]       4364.2982    211.344     20.650      0.000      3950.060  4778.536
UNIT[T.R033]       8152.9155    211.074     38.626      0.000      7739.206  8566.625
UNIT[T.R034]       1034.0180    215.726      4.793      0.000       611.191  1456.845
UNIT[T.R035]       2712.1732    211.615     12.817      0.000      2297.403  3126.943
UNIT[T.R036]        638.2875    213.589      2.988      0.003       219.648  1056.927
UNIT[T.R037]        762.2512    211.884      3.597      0.000       346.954  1177.548
UNIT[T.R038]        106.8107    214.184      0.499      0.618      -312.995   526.616
UNIT[T.R039]        633.8331    217.008      2.921      0.003       208.494  1059.172
UNIT[T.R040]       1164.5060    211.608      5.503      0.000       749.750  1579.262
UNIT[T.R041]       3017.9478    211.074     14.298      0.000      2604.238  3431.657
UNIT[T.R042]        500.8132    212.731      2.354      0.019        83.855   917.771
UNIT[T.R043]       2805.0822    211.074     13.290      0.000      2391.373  3218.792
UNIT[T.R044]       4596.4908    211.074     21.777      0.000      4182.781  5010.200
UNIT[T.R046]       8262.9424    211.074     39.147      0.000      7849.233  8676.652
UNIT[T.R049]       2690.7542    211.074     12.748      0.000      2277.045  3104.464
UNIT[T.R050]       3946.2889    211.616     18.648      0.000      3531.518  4361.060
UNIT[T.R051]       5052.4961    211.074     23.937      0.000      4638.787  5466.206
UNIT[T.R052]       1113.6527    215.094      5.178      0.000       692.063  1535.242
UNIT[T.R053]       3087.7555    211.608     14.592      0.000      2672.999  3502.512
UNIT[T.R054]       1376.6247    211.616      6.505      0.000       961.854  1791.395
UNIT[T.R055]       8255.7174    211.067     39.114      0.000      7842.022  8669.413
UNIT[T.R056]       1360.2275    211.615      6.428      0.000       945.457  1774.998
UNIT[T.R057]       4800.8832    211.074     22.745      0.000      4387.174  5214.593
UNIT[T.R058]        558.4808    211.340      2.643      0.008       144.249   972.712
UNIT[T.R059]       1099.4629    213.597      5.147      0.000       680.808  1518.117
UNIT[T.R060]        705.0957    212.730      3.315      0.001       288.140  1122.051
UNIT[T.R061]        494.3867    216.686      2.282      0.023        69.677   919.096
UNIT[T.R062]       2654.7435    211.074     12.577      0.000      2241.034  3068.453
UNIT[T.R063]       1041.1556    216.364      4.812      0.000       617.077  1465.234
UNIT[T.R064]        749.6503    213.895      3.505      0.000       330.412  1168.889
UNIT[T.R065]        746.7748    215.101      3.472      0.001       325.172  1168.378
UNIT[T.R066]        140.0743    215.727      0.649      0.516      -282.754   562.903
UNIT[T.R067]        761.7603    216.679      3.516      0.000       337.065  1186.455
UNIT[T.R068]        354.1350    216.679      1.634      0.102       -70.560   778.830
UNIT[T.R069]        845.0370    214.787      3.934      0.000       424.049  1266.025
UNIT[T.R070]       1705.7220    211.074      8.081      0.000      1292.013  2119.431
UNIT[T.R080]       3530.0499    211.074     16.724      0.000      3116.341  3943.759
UNIT[T.R081]       3482.8728    211.618     16.458      0.000      3068.096  3897.649
UNIT[T.R082]       1420.6519    211.616      6.713      0.000      1005.881  1835.423
UNIT[T.R083]       3044.4585    211.074     14.424      0.000      2630.749  3458.168
UNIT[T.R084]       9948.7327    211.074     47.134      0.000      9535.023  1.04e+04
UNIT[T.R085]       2529.3610    211.617     11.953      0.000      2114.587  2944.135
UNIT[T.R086]       2518.0499    211.074     11.930      0.000      2104.341  2931.759
UNIT[T.R087]       1141.2501    212.168      5.379      0.000       725.397  1557.103
UNIT[T.R089]        431.2221    211.615      2.038      0.042        16.452   845.992
UNIT[T.R090]        330.4675    216.680      1.525      0.127       -94.230   755.165
UNIT[T.R091]       1041.0580    215.720      4.826      0.000       618.242  1463.874
UNIT[T.R092]       1919.3675    213.888      8.974      0.000      1500.143  2338.592
UNIT[T.R093]       1948.0487    214.486      9.082      0.000      1527.652  2368.446
UNIT[T.R094]       1689.9032    211.608      7.986      0.000      1275.147  2104.660
UNIT[T.R095]       2097.4793    212.441      9.873      0.000      1681.090  2513.869
UNIT[T.R096]       2283.1693    211.336     10.803      0.000      1868.946  2697.393
UNIT[T.R097]       2903.2228    211.336     13.737      0.000      2489.000  3317.446
UNIT[T.R098]       1752.6090    211.074      8.303      0.000      1338.900  2166.318
UNIT[T.R099]       2309.6359    211.074     10.942      0.000      1895.927  2723.345
UNIT[T.R100]        489.4973    212.163      2.307      0.021        73.653   905.341
UNIT[T.R101]       2744.0284    211.074     13.000      0.000      2330.319  3157.738
UNIT[T.R102]       3632.8671    211.074     17.211      0.000      3219.158  4046.577
UNIT[T.R103]       1313.4097    215.096      6.106      0.000       891.818  1735.002
UNIT[T.R104]       1277.8267    211.608      6.039      0.000       863.070  1692.583
UNIT[T.R105]       3282.5660    211.074     15.552      0.000      2868.857  3696.275
UNIT[T.R106]        977.0366    216.679      4.509      0.000       552.341  1401.733
UNIT[T.R107]        393.3922    217.006      1.813      0.070       -31.944   818.729
UNIT[T.R108]       5171.7327    211.074     24.502      0.000      4758.023  5585.442
UNIT[T.R111]       3168.8564    211.074     15.013      0.000      2755.147  3582.566
UNIT[T.R112]       1624.8558    211.336      7.688      0.000      1210.632  2039.079
UNIT[T.R114]        841.4415    211.338      3.981      0.000       427.214  1255.669
UNIT[T.R115]       1212.8581    211.067      5.746      0.000       799.162  1626.554
UNIT[T.R116]       3148.0015    211.074     14.914      0.000      2734.292  3561.711
UNIT[T.R117]        789.1464    216.355      3.647      0.000       365.085  1213.207
UNIT[T.R119]       1791.5990    213.009      8.411      0.000      1374.097  2209.101
UNIT[T.R120]       1448.6969    214.485      6.754      0.000      1028.303  1869.091
UNIT[T.R121]       1400.4923    213.892      6.548      0.000       981.260  1819.725
UNIT[T.R122]       2518.0924    212.445     11.853      0.000      2101.697  2934.488
UNIT[T.R123]       1569.1237    212.732      7.376      0.000      1152.164  1986.083
UNIT[T.R124]        578.6125    215.409      2.686      0.007       156.406  1000.819
UNIT[T.R126]       1809.9101    211.074      8.575      0.000      1396.201  2223.620
UNIT[T.R127]       4750.6198    211.074     22.507      0.000      4336.910  5164.329
UNIT[T.R137]       2401.6260    211.067     11.378      0.000      1987.930  2815.322
UNIT[T.R139]       2484.5788    211.343     11.756      0.000      2070.342  2898.816
UNIT[T.R163]       3286.3564    211.074     15.570      0.000      2872.647  3700.066
UNIT[T.R172]       1852.3940    211.074      8.776      0.000      1438.685  2266.103
UNIT[T.R179]       6733.1682    211.074     31.900      0.000      6319.459  7146.878
UNIT[T.R181]       1704.5535    213.016      8.002      0.000      1287.038  2122.069
UNIT[T.R183]        677.0282    217.006      3.120      0.002       251.692  1102.365
UNIT[T.R184]        924.0028    215.725      4.283      0.000       501.177  1346.828
UNIT[T.R186]       1032.1082    212.448      4.858      0.000       615.705  1448.511
UNIT[T.R188]       2286.0009    211.344     10.817      0.000      1871.763  2700.239
UNIT[T.R189]       1340.5627    213.595      6.276      0.000       921.911  1759.214
UNIT[T.R194]       1951.0878    213.019      9.159      0.000      1533.566  2368.609
UNIT[T.R196]       1283.4144    211.890      6.057      0.000       868.105  1698.724
UNIT[T.R198]       2069.1302    211.616      9.778      0.000      1654.359  2483.901
UNIT[T.R199]        671.0317    213.017      3.150      0.002       253.514  1088.549
UNIT[T.R200]       1010.1864    212.162      4.761      0.000       594.345  1426.028
UNIT[T.R202]       2187.6562    211.611     10.338      0.000      1772.894  2602.419
UNIT[T.R203]       1712.6087    214.189      7.996      0.000      1292.793  2132.424
UNIT[T.R204]       1413.8940    211.074      6.699      0.000      1000.185  1827.603
UNIT[T.R205]       1469.1511    212.161      6.925      0.000      1053.311  1884.992
UNIT[T.R207]       1963.3144    211.344      9.290      0.000      1549.077  2377.552
UNIT[T.R208]       2469.6364    212.160     11.640      0.000      2053.798  2885.475
UNIT[T.R209]        718.8887    216.363      3.323      0.001       294.813  1142.964
UNIT[T.R210]        486.2021    213.597      2.276      0.023        67.548   904.856
UNIT[T.R211]       2371.3241    211.074     11.235      0.000      1957.615  2785.034
UNIT[T.R212]       1651.5355    211.343      7.814      0.000      1237.298  2065.773
UNIT[T.R213]       1103.7525    213.306      5.175      0.000       685.668  1521.837
UNIT[T.R214]        592.5124    216.686      2.734      0.006       167.803  1017.222
UNIT[T.R215]       1560.1051    211.617      7.372      0.000      1145.332  1974.879
UNIT[T.R216]        730.3372    211.616      3.451      0.001       315.566  1145.108
UNIT[T.R217]        936.9401    216.364      4.330      0.000       512.862  1361.018
UNIT[T.R218]       1947.6720    211.336      9.216      0.000      1533.448  2361.895
UNIT[T.R219]       1228.4325    211.610      5.805      0.000       813.673  1643.192
UNIT[T.R220]       1446.0499    211.074      6.851      0.000      1032.341  1859.759
UNIT[T.R221]       1338.0539    216.686      6.175      0.000       913.344  1762.763
UNIT[T.R223]       2087.1152    211.336      9.876      0.000      1672.892  2501.339
UNIT[T.R224]        678.2576    213.888      3.171      0.002       259.033  1097.482
UNIT[T.R225]        536.9740    212.449      2.528      0.011       120.569   953.379
UNIT[T.R226]        653.4627    215.718      3.029      0.002       230.652  1076.274
UNIT[T.R227]       1065.3133    211.074      5.047      0.000       651.604  1479.023
UNIT[T.R228]       1076.4010    216.045      4.982      0.000       652.949  1499.853
UNIT[T.R229]        513.2913    215.413      2.383      0.017        91.077   935.505
UNIT[T.R230]        464.6424    214.189      2.169      0.030        44.827   884.458
UNIT[T.R231]        927.0856    212.448      4.364      0.000       510.683  1343.488
UNIT[T.R232]        962.1030    215.101      4.473      0.000       540.502  1383.704
UNIT[T.R233]       1028.3698    217.345      4.732      0.000       602.370  1454.370
UNIT[T.R234]        244.9310    216.365      1.132      0.258      -179.148   669.010
UNIT[T.R235]       2536.5835    211.340     12.002      0.000      2122.352  2950.815
UNIT[T.R236]       1484.9488    212.160      6.999      0.000      1069.111  1900.787
UNIT[T.R237]        591.0004    216.035      2.736      0.006       167.567  1014.434
UNIT[T.R238]       2069.8179    211.336      9.794      0.000      1655.594  2484.041
UNIT[T.R239]        862.4746    211.074      4.086      0.000       448.765  1276.184
UNIT[T.R240]       2622.2450    211.890     12.375      0.000      2206.936  3037.554
UNIT[T.R242]        501.4669    213.306      2.351      0.019        83.383   919.550
UNIT[T.R243]       1324.5256    214.788      6.167      0.000       903.537  1745.515
UNIT[T.R244]       1561.4595    214.794      7.270      0.000      1140.459  1982.460
UNIT[T.R246]        613.5070    216.043      2.840      0.005       190.058  1036.956
UNIT[T.R247]         64.1953    218.017      0.294      0.768      -363.122   491.513
UNIT[T.R248]       3066.9085    211.343     14.511      0.000      2652.671  3481.146
UNIT[T.R249]       1313.8455    212.731      6.176      0.000       896.888  1730.803
UNIT[T.R250]        928.3981    213.306      4.352      0.000       510.315  1346.482
UNIT[T.R251]       1236.1617    211.889      5.834      0.000       820.855  1651.468
UNIT[T.R252]        922.0867    211.616      4.357      0.000       507.316  1336.857
UNIT[T.R253]        695.3141    215.107      3.232      0.001       273.701  1116.927
UNIT[T.R254]       2557.7271    211.338     12.103      0.000      2143.500  2971.954
UNIT[T.R255]        728.4068    212.161      3.433      0.001       312.568  1144.246
UNIT[T.R256]       1026.5334    211.617      4.851      0.000       611.760  1441.307
UNIT[T.R257]       1849.6467    211.074      8.763      0.000      1435.937  2263.356
UNIT[T.R258]       1485.6275    211.891      7.011      0.000      1070.316  1900.939
UNIT[T.R259]        885.8406    212.730      4.164      0.000       468.885  1302.796
UNIT[T.R260]       1054.5445    220.489      4.783      0.000       622.381  1486.708
UNIT[T.R261]       1516.2964    213.590      7.099      0.000      1097.656  1934.937
UNIT[T.R262]        375.8899    218.019      1.724      0.085       -51.432   803.212
UNIT[T.R263]         85.6263    213.308      0.401      0.688      -332.461   503.713
UNIT[T.R264]        437.3533    211.345      2.069      0.039        23.113   851.594
UNIT[T.R265]        799.7812    215.413      3.713      0.000       377.568  1221.994
UNIT[T.R266]        869.4233    211.336      4.114      0.000       455.200  1283.647
UNIT[T.R269]        843.6644    211.617      3.987      0.000       428.891  1258.438
UNIT[T.R270]        417.6986    216.042      1.933      0.053        -5.748   841.145
UNIT[T.R271]        295.7651    215.726      1.371      0.170      -127.063   718.593
UNIT[T.R273]       1299.4535    216.365      6.006      0.000       875.374  1723.533
UNIT[T.R274]        898.1465    215.106      4.175      0.000       476.535  1319.758
UNIT[T.R275]        844.8063    213.591      3.955      0.000       426.163  1263.449
UNIT[T.R276]       1372.1843    211.074      6.501      0.000       958.475  1785.894
UNIT[T.R277]        349.2636    219.055      1.594      0.111       -80.088   778.616
UNIT[T.R278]        304.4507    215.412      1.413      0.158      -117.760   726.662
UNIT[T.R279]        711.6433    213.009      3.341      0.001       294.141  1129.145
UNIT[T.R280]        581.4729    218.354      2.663      0.008       153.495  1009.451
UNIT[T.R281]       1235.2352    212.732      5.807      0.000       818.276  1652.194
UNIT[T.R282]       1540.5486    211.616      7.280      0.000      1125.778  1955.319
UNIT[T.R284]        730.4834    211.616      3.452      0.001       315.713  1145.254
UNIT[T.R285]        509.1773    216.680      2.350      0.019        84.480   933.875
UNIT[T.R287]        465.1478    217.015      2.143      0.032        39.793   890.502
UNIT[T.R291]       1765.4155    211.074      8.364      0.000      1351.706  2179.125
UNIT[T.R294]        885.0390    213.599      4.143      0.000       466.381  1303.697
UNIT[T.R295]        514.1238    227.817      2.257      0.024        67.598   960.649
UNIT[T.R300]       2174.4800    211.074     10.302      0.000      1760.771  2588.189
UNIT[T.R303]       1181.1908    212.732      5.552      0.000       764.231  1598.151
UNIT[T.R304]       1039.7508    211.617      4.913      0.000       624.977  1454.524
UNIT[T.R307]        241.7606    217.006      1.114      0.265      -183.576   667.097
UNIT[T.R308]        718.4996    214.787      3.345      0.001       297.513  1139.486
UNIT[T.R309]        751.5610    214.487      3.504      0.000       331.163  1171.959
UNIT[T.R310]       1202.5574    215.718      5.575      0.000       779.746  1625.369
UNIT[T.R311]        322.4222    214.190      1.505      0.132       -97.395   742.239
UNIT[T.R312]        279.6434    211.890      1.320      0.187      -135.666   694.952
UNIT[T.R313]        -50.1934    217.337     -0.231      0.817      -476.178   375.791
UNIT[T.R318]        486.4810    212.166      2.293      0.022        70.630   902.331
UNIT[T.R319]       1288.2639    213.018      6.048      0.000       870.744  1705.784
UNIT[T.R321]       1037.0768    211.074      4.913      0.000       623.367  1450.786
UNIT[T.R322]       1719.9380    213.020      8.074      0.000      1302.414  2137.462
UNIT[T.R323]       1184.8828    215.103      5.508      0.000       763.277  1606.488
UNIT[T.R325]        261.5179    214.182      1.221      0.222      -158.284   681.320
UNIT[T.R330]        917.6693    213.600      4.296      0.000       499.010  1336.329
UNIT[T.R335]        278.4820    217.671      1.279      0.201      -148.158   705.122
UNIT[T.R336]        -86.6639    217.671     -0.398      0.691      -513.304   339.976
UNIT[T.R337]        -33.7918    216.356     -0.156      0.876      -457.855   390.271
UNIT[T.R338]       -149.2196    214.484     -0.696      0.487      -569.613   271.174
UNIT[T.R341]        434.9128    211.884      2.053      0.040        19.615   850.210
UNIT[T.R344]        384.5815    217.678      1.767      0.077       -42.073   811.236
UNIT[T.R345]        384.2600    214.189      1.794      0.073       -35.556   804.076
UNIT[T.R346]       1175.7727    214.493      5.482      0.000       755.362  1596.183
UNIT[T.R348]         37.2557    214.483      0.174      0.862      -383.134   457.646
UNIT[T.R354]         84.5718    216.680      0.390      0.696      -340.125   509.268
UNIT[T.R356]       1014.2371    213.889      4.742      0.000       595.010  1433.464
UNIT[T.R358]        109.6844    216.679      0.506      0.613      -315.012   534.381
UNIT[T.R370]        389.4751    213.893      1.821      0.069       -29.759   808.709
UNIT[T.R371]        605.3028    215.099      2.814      0.005       183.704  1026.901
UNIT[T.R372]        588.4894    216.044      2.724      0.006       165.040  1011.939
UNIT[T.R373]        536.0482    216.364      2.478      0.013       111.969   960.127
UNIT[T.R382]        814.6732    213.590      3.814      0.000       396.033  1233.314
UNIT[T.R424]        245.8998    217.341      1.131      0.258      -180.093   671.892
UNIT[T.R429]        929.0759    211.883      4.385      0.000       513.782  1344.370
UNIT[T.R453]       1678.7294    218.360      7.688      0.000      1250.740  2106.719
UNIT[T.R454]         -3.4266    216.688     -0.016      0.987      -428.139   421.285
UNIT[T.R455]        -52.5719    216.365     -0.243      0.808      -476.652   371.509
UNIT[T.R456]        135.9838    213.599      0.637      0.524      -282.674   554.642
UNIT[T.R459]        -46.5100    260.940     -0.178      0.859      -557.958   464.938
UNIT[T.R464]       -219.9875    216.036     -1.018      0.309      -643.422   203.447
C(hour)[T.8]        282.6097     34.719      8.140      0.000       214.560   350.659
C(hour)[T.12]      2687.8018     32.751     82.067      0.000      2623.609  2751.995
C(hour)[T.16]      1985.5882     32.738     60.651      0.000      1921.421  2049.755
C(hour)[T.20]      2905.1814     32.771     88.650      0.000      2840.949  2969.414
C(hour)[T.24]      1129.3470     32.652     34.588      0.000      1065.349  1193.345
precipi           -1200.9817    377.184     -3.184      0.001     -1940.270  -461.693
==============================================================================
Omnibus:                    30389.520   Durbin-Watson:                   1.550
Prob(Omnibus):                  0.000   Jarque-Bera (JB):          1133111.735
Skew:                           2.993   Prob(JB):                         0.00
Kurtosis:                      27.532   Cond. No.                         220.
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

In [62]:
plt.plot([0,20000],[0,20000])
plt.scatter(df.ENTRIESn_hourly,res.predict())


Out[62]:
<matplotlib.collections.PathCollection at 0x10e773890>

In [14]:
mydf2 = df.pivot_table(values='ENTRIESn_hourly', index=['day','weekday','hour_str','precipi'], aggfunc=np.sum).reset_index()
mod = sm.OLS.from_formula('ENTRIESn_hourly ~ precipi + weekday + hour_str', data=mydf2)
res = mod.fit()
print res.summary()


                            OLS Regression Results                            
==============================================================================
Dep. Variable:        ENTRIESn_hourly   R-squared:                       0.753
Model:                            OLS   Adj. R-squared:                  0.745
Method:                 Least Squares   F-statistic:                     87.61
Date:                Fri, 31 Jul 2015   Prob (F-statistic):           1.37e-57
Time:                        14:56:33   Log-Likelihood:                -2796.4
No. Observations:                 209   AIC:                             5609.
Df Residuals:                     201   BIC:                             5635.
Df Model:                           7                                         
Covariance Type:            nonrobust                                         
===================================================================================
                      coef    std err          t      P>|t|      [95.0% Conf. Int.]
-----------------------------------------------------------------------------------
Intercept        5.247e+05   3.24e+04     16.177      0.000      4.61e+05  5.89e+05
weekday[T.True]  2.098e+05   2.41e+04      8.716      0.000      1.62e+05  2.57e+05
hour_str[T.16]  -1.754e+05    3.9e+04     -4.499      0.000     -2.52e+05 -9.85e+04
hour_str[T.20]   7.171e+04   3.96e+04      1.811      0.072     -6364.734   1.5e+05
hour_str[T.24]  -3.471e+05   3.94e+04     -8.817      0.000     -4.25e+05 -2.69e+05
hour_str[T.4]    -5.92e+05   3.88e+04    -15.253      0.000     -6.69e+05 -5.15e+05
hour_str[T.8]   -5.259e+05   3.75e+04    -14.017      0.000        -6e+05 -4.52e+05
precipi         -1.118e+06   3.14e+05     -3.560      0.000     -1.74e+06 -4.99e+05
==============================================================================
Omnibus:                       88.410   Durbin-Watson:                   2.074
Prob(Omnibus):                  0.000   Jarque-Bera (JB):              327.603
Skew:                          -1.718   Prob(JB):                     7.27e-72
Kurtosis:                       8.080   Cond. No.                         37.1
==============================================================================

Warnings:
[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.

In [15]:
len(df)


Out[15]:
42649

In [16]:
sm.qqplot((mydf2.ENTRIESn_hourly-res.predict()))
plt.show()



In [17]:
plt.plot([0,1000000],[0,1000000])
plt.scatter(mydf2.ENTRIESn_hourly,res.predict())


Out[17]:
<matplotlib.collections.PathCollection at 0x10ad31290>

In [18]:
def rsquared(x, y):
    """ Return R^2 where x and y are array-like.

    http://stackoverflow.com/questions/893657/how-do-i-calculate-r-squared-using-python-and-numpy
    """

    slope, intercept, r_value, p_value, std_err = sps.linregress(x, y)
    return r_value**2

In [19]:
rsquared(df.ENTRIESn_hourly,res.predict())


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-19-ed3aec44d8e3> in <module>()
----> 1 rsquared(df.ENTRIESn_hourly,res.predict())

<ipython-input-18-9612bef57a51> in rsquared(x, y)
      5     """
      6 
----> 7     slope, intercept, r_value, p_value, std_err = sps.linregress(x, y)
      8     return r_value**2

/anaconda/lib/python2.7/site-packages/scipy/stats/stats.pyc in linregress(x, y)
   3049 
   3050     # average sum of squares:
-> 3051     ssxm, ssxym, ssyxm, ssym = np.cov(x, y, bias=1).flat
   3052     r_num = ssxym
   3053     r_den = np.sqrt(ssxm*ssym)

/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyc in cov(m, y, rowvar, bias, ddof)
   1893     if y is not None:
   1894         y = array(y, copy=False, ndmin=2, dtype=dtype)
-> 1895         X = concatenate((X, y), axis)
   1896 
   1897     X -= X.mean(axis=1-axis, keepdims=True)

ValueError: all the input array dimensions except for the concatenation axis must match exactly

In [20]:
plt.hist(df.ENTRIESn_hourly-res.predict(), bins=100)
plt.show()


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-20-cc443b2eb156> in <module>()
----> 1 plt.hist(df.ENTRIESn_hourly-res.predict(), bins=100)
      2 plt.show()

/anaconda/lib/python2.7/site-packages/pandas/core/ops.pyc in wrapper(left, right, name)
    530             if hasattr(lvalues, 'values'):
    531                 lvalues = lvalues.values
--> 532             return left._constructor(wrap_results(na_op(lvalues, rvalues)),
    533                                      index=left.index, name=left.name,
    534                                      dtype=dtype)

/anaconda/lib/python2.7/site-packages/pandas/core/ops.pyc in na_op(x, y)
    467         try:
    468             result = expressions.evaluate(op, str_rep, x, y,
--> 469                                           raise_on_error=True, **eval_kwargs)
    470         except TypeError:
    471             if isinstance(y, (np.ndarray, pd.Series, pd.Index)):

/anaconda/lib/python2.7/site-packages/pandas/computation/expressions.pyc in evaluate(op, op_str, a, b, raise_on_error, use_numexpr, **eval_kwargs)
    216     if use_numexpr:
    217         return _evaluate(op, op_str, a, b, raise_on_error=raise_on_error,
--> 218                          **eval_kwargs)
    219     return _evaluate_standard(op, op_str, a, b, raise_on_error=raise_on_error)
    220 

/anaconda/lib/python2.7/site-packages/pandas/computation/expressions.pyc in _evaluate_numexpr(op, op_str, a, b, raise_on_error, truediv, reversed, **eval_kwargs)
    127 
    128     if result is None:
--> 129         result = _evaluate_standard(op, op_str, a, b, raise_on_error)
    130 
    131     return result

/anaconda/lib/python2.7/site-packages/pandas/computation/expressions.pyc in _evaluate_standard(op, op_str, a, b, raise_on_error, **eval_kwargs)
     69     if _TEST_MODE:
     70         _store_test_result(False)
---> 71     return op(a, b)
     72 
     73 

ValueError: operands could not be broadcast together with shapes (42649,) (209,) 

In [21]:
sns.set_style('white')
df.hist(column='ENTRIESn_hourly', by='rain', bins=np.arange(0,15000,1000), sharey=True, figsize=[14,8])
sns.despine(left=True)



In [23]:
df.columns


Out[23]:
Index([u'UNIT', u'DATEn', u'TIMEn', u'ENTRIESn', u'EXITSn', u'ENTRIESn_hourly',
       u'EXITSn_hourly', u'datetime', u'hour', u'day_week', u'weekday',
       u'station', u'latitude', u'longitude', u'conds', u'fog', u'precipi',
       u'pressurei', u'rain', u'tempi', u'wspdi', u'meanprecipi',
       u'meanpressurei', u'meantempi', u'meanwspdi', u'weather_lat',
       u'weather_lon', u'day', u'hour_str', u'day_str'],
      dtype='object')

In [36]:
plt.figure(figsize=[8,6])
sns.heatmap(
    df[['ENTRIESn_hourly','EXITSn_hourly','day_week','weekday','day','hour','fog','precipi','rain','tempi','wspdi']].corr(),
    )


Out[36]:
<matplotlib.axes._subplots.AxesSubplot at 0x1105c0d90>

In [50]:
import matplotlib as mpl

In [51]:
plt.scatter(mpl.dates.date2num(df.datetime), df.tempi)


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-51-1c2d10411298> in <module>()
----> 1 plt.scatter(mpl.dates.date2num(df.datetime), df.tempi)

/anaconda/lib/python2.7/site-packages/matplotlib/dates.pyc in date2num(d)
    308         if not d.size:
    309             return d
--> 310         return _to_ordinalf_np_vectorized(d)
    311 
    312 

/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyc in __call__(self, *args, **kwargs)
   1698             vargs.extend([kwargs[_n] for _n in names])
   1699 
-> 1700         return self._vectorize_call(func=func, args=vargs)
   1701 
   1702     def _get_ufunc_and_otypes(self, func, args):

/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyc in _vectorize_call(self, func, args)
   1761             _res = func()
   1762         else:
-> 1763             ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
   1764 
   1765             # Convert args to object arrays first

/anaconda/lib/python2.7/site-packages/numpy/lib/function_base.pyc in _get_ufunc_and_otypes(self, func, args)
   1723             # arrays (the input values are not checked to ensure this)
   1724             inputs = [asarray(_a).flat[0] for _a in args]
-> 1725             outputs = func(*inputs)
   1726 
   1727             # Performance note: profiling indicates that -- for simple

/anaconda/lib/python2.7/site-packages/matplotlib/dates.pyc in _to_ordinalf(dt)
    202             dt -= delta
    203 
--> 204     base = float(dt.toordinal())
    205     if hasattr(dt, 'hour'):
    206         base += (dt.hour / HOURS_PER_DAY + dt.minute / MINUTES_PER_DAY +

AttributeError: 'numpy.datetime64' object has no attribute 'toordinal'

In [22]:
sns.distplot(df.ENTRIESn_hourly, kde=False, fit=sps.lognorm)
sns.despine(left=True)
plt.xlim(xmin=0)


Out[22]:
(0, 35000.0)

In [ ]:
df.columns

In [ ]:
sns.pairplot(df[[')


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-272-033902782ad7> in <module>()
----> 1 sns.pairplot(df)

/anaconda/lib/python2.7/site-packages/seaborn/linearmodels.pyc in pairplot(data, hue, hue_order, palette, vars, x_vars, y_vars, kind, diag_kind, markers, size, aspect, dropna, plot_kws, diag_kws, grid_kws)
   1581                     hue_order=hue_order, palette=palette,
   1582                     diag_sharey=diag_sharey,
-> 1583                     size=size, aspect=aspect, dropna=dropna, **grid_kws)
   1584 
   1585     # Add the markers here as PairGrid has figured out how many levels of the

/anaconda/lib/python2.7/site-packages/seaborn/axisgrid.pyc in __init__(self, data, hue, hue_order, palette, hue_kws, vars, x_vars, y_vars, diag_sharey, size, aspect, despine, dropna)
   1200                                  figsize=figsize,
   1201                                  sharex="col", sharey="row",
-> 1202                                  squeeze=False)
   1203 
   1204         self.fig = fig

/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.pyc in subplots(nrows, ncols, sharex, sharey, squeeze, subplot_kw, gridspec_kw, **fig_kw)
   1115         else:
   1116             subplot_kw['sharey'] = axarr[sys[i]]
-> 1117         axarr[i] = fig.add_subplot(gs[i // ncols, i % ncols], **subplot_kw)
   1118 
   1119     # returned axis array will be always 2-d, even if nrows=ncols=1

/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in add_subplot(self, *args, **kwargs)
    962                     self._axstack.remove(ax)
    963 
--> 964             a = subplot_class_factory(projection_class)(self, *args, **kwargs)
    965 
    966         self._axstack.add(key, a)

/anaconda/lib/python2.7/site-packages/matplotlib/axes/_subplots.pyc in __init__(self, fig, *args, **kwargs)
     76 
     77         # _axes_class is set in the subplot_class_factory
---> 78         self._axes_class.__init__(self, fig, self.figbox, **kwargs)
     79 
     80     def __reduce__(self):

/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in __init__(self, fig, rect, axisbg, frameon, sharex, sharey, label, xscale, yscale, **kwargs)
    423 
    424         # this call may differ for non-sep axes, e.g., polar
--> 425         self._init_axis()
    426 
    427         if axisbg is None:

/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _init_axis(self)
    482         self.xaxis = maxis.XAxis(self)
    483         self.spines['bottom'].register_axis(self.xaxis)
--> 484         self.spines['top'].register_axis(self.xaxis)
    485         self.yaxis = maxis.YAxis(self)
    486         self.spines['left'].register_axis(self.yaxis)

/anaconda/lib/python2.7/site-packages/matplotlib/spines.pyc in register_axis(self, axis)
    155         self.axis = axis
    156         if self.axis is not None:
--> 157             self.axis.cla()
    158 
    159     def cla(self):

/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in cla(self)
    752         self._set_artist_props(self.label)
    753 
--> 754         self.reset_ticks()
    755 
    756         self.converter = None

/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in reset_ticks(self)
    766 
    767         self.majorTicks.extend([self._get_tick(major=True)])
--> 768         self.minorTicks.extend([self._get_tick(major=False)])
    769         self._lastNumMajorTicks = 1
    770         self._lastNumMinorTicks = 1

/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in _get_tick(self, major)
   1660         else:
   1661             tick_kw = self._minor_tick_kw
-> 1662         return XTick(self.axes, 0, '', major=major, **tick_kw)
   1663 
   1664     def _get_label(self):

/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in __init__(self, axes, loc, label, size, width, color, tickdir, pad, labelsize, labelcolor, zorder, gridOn, tick1On, tick2On, label1On, label2On, major)
    147 
    148         self.tick1line = self._get_tick1line()
--> 149         self.tick2line = self._get_tick2line()
    150         self.gridline = self._get_gridline()
    151 

/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in _get_tick2line(self)
    411                        markersize=self._size,
    412                        markeredgewidth=self._width,
--> 413                        zorder=self._zorder,
    414                        )
    415 

/anaconda/lib/python2.7/site-packages/matplotlib/lines.pyc in __init__(self, xdata, ydata, linewidth, linestyle, color, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor, markerfacecoloralt, fillstyle, antialiased, dash_capstyle, solid_capstyle, dash_joinstyle, solid_joinstyle, pickradius, drawstyle, markevery, **kwargs)
    335         self.set_markeredgecolor(markeredgecolor)
    336         self.set_markeredgewidth(markeredgewidth)
--> 337         self.set_fillstyle(fillstyle)
    338 
    339         self.verticalOffset = None

/anaconda/lib/python2.7/site-packages/matplotlib/lines.pyc in set_fillstyle(self, fs)
    457         ACCEPTS: ['full' | 'left' | 'right' | 'bottom' | 'top' | 'none']
    458         """
--> 459         self._marker.set_fillstyle(fs)
    460 
    461     def set_markevery(self, every):

/anaconda/lib/python2.7/site-packages/matplotlib/markers.pyc in set_fillstyle(self, fillstyle)
    216                              % ' '.join(self.fillstyles))
    217         self._fillstyle = fillstyle
--> 218         self._recache()
    219 
    220     def get_joinstyle(self):

/anaconda/lib/python2.7/site-packages/matplotlib/markers.pyc in _recache(self)
    189         self._capstyle = 'butt'
    190         self._filled = True
--> 191         self._marker_function()
    192 
    193     if six.PY3:

/anaconda/lib/python2.7/site-packages/matplotlib/markers.pyc in _set_tickup(self)
    692 
    693     def _set_tickup(self):
--> 694         self._transform = Affine2D().scale(1.0, 1.0)
    695         self._snap_threshold = 1.0
    696         self._filled = False

/anaconda/lib/python2.7/site-packages/matplotlib/transforms.pyc in scale(self, sx, sy)
   1915             np.float_)
   1916         self._mtx = np.dot(scale_mtx, self._mtx)
-> 1917         self.invalidate()
   1918         return self
   1919 

KeyboardInterrupt: 
Traceback (most recent call last):

  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/ipkernel.py", line 181, in do_execute
    shell.run_cell(code, store_history=store_history, silent=silent)

  File "/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2874, in run_cell
    self.events.trigger('post_execute')

  File "/anaconda/lib/python2.7/site-packages/IPython/core/events.py", line 74, in trigger
    func(*args, **kwargs)

  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/pylab/backend_inline.py", line 109, in flush_figures
    return show(True)

  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/pylab/backend_inline.py", line 32, in show
    display(figure_manager.canvas.figure)

  File "/anaconda/lib/python2.7/site-packages/IPython/core/display.py", line 159, in display
    format_dict, md_dict = format(obj, include=include, exclude=exclude)

  File "/anaconda/lib/python2.7/site-packages/IPython/core/formatters.py", line 179, in format
    data = formatter(obj)

  File "<string>", line 2, in __call__

  File "/anaconda/lib/python2.7/site-packages/IPython/core/formatters.py", line 224, in catch_format_error
    r = method(self, *args, **kwargs)

  File "/anaconda/lib/python2.7/site-packages/IPython/core/formatters.py", line 335, in __call__
    return printer(obj)

  File "/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.py", line 207, in <lambda>
    png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))

  File "/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.py", line 117, in print_figure
    fig.canvas.print_figure(bytes_io, **kw)

  File "/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2214, in print_figure
    restore_bbox()

  File "/anaconda/lib/python2.7/site-packages/matplotlib/tight_bbox.py", line 50, in restore_bbox
    fig.transFigure.invalidate()

  File "/anaconda/lib/python2.7/site-packages/matplotlib/transforms.py", line 135, in invalidate
    return self._invalidate_internal(value, invalidating_node=self)

  File "/anaconda/lib/python2.7/site-packages/matplotlib/transforms.py", line 159, in _invalidate_internal
    invalidating_node=self)

  File "/anaconda/lib/python2.7/site-packages/matplotlib/transforms.py", line 159, in _invalidate_internal
    invalidating_node=self)

  File "/anaconda/lib/python2.7/site-packages/matplotlib/transforms.py", line 157, in _invalidate_internal
    for parent in list(six.itervalues(self._parents)):

KeyboardInterrupt
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
  File "/anaconda/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 407, in _run_callback
    callback(*args, **kwargs)
  File "/anaconda/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 252, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 213, in dispatch_shell
    handler(stream, idents, msg)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 388, in execute_request
    self._abort_queues()
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 588, in _abort_queues
    self._abort_queue(stream)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 611, in _abort_queue
    poller.poll(50)
  File "/anaconda/lib/python2.7/site-packages/zmq/sugar/poll.py", line 101, in poll
    return zmq_poll(self.sockets, timeout=timeout)
  File "zmq/backend/cython/_poll.pyx", line 115, in zmq.backend.cython._poll.zmq_poll (zmq/backend/cython/_poll.c:1625)
  File "zmq/backend/cython/checkrc.pxd", line 12, in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/_poll.c:1958)
    PyErr_CheckSignals()
KeyboardInterrupt
ERROR:tornado.general:Uncaught exception, closing connection.
Traceback (most recent call last):
  File "/anaconda/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 433, in _handle_events
    self._handle_recv()
  File "/anaconda/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 465, in _handle_recv
    self._run_callback(callback, msg)
  File "/anaconda/lib/python2.7/site-packages/zmq/eventloop/zmqstream.py", line 407, in _run_callback
    callback(*args, **kwargs)
  File "/anaconda/lib/python2.7/site-packages/tornado/stack_context.py", line 275, in null_wrapper
    return fn(*args, **kwargs)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 252, in dispatcher
    return self.dispatch_shell(stream, msg)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 213, in dispatch_shell
    handler(stream, idents, msg)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 388, in execute_request
    self._abort_queues()
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 588, in _abort_queues
    self._abort_queue(stream)
  File "/anaconda/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 611, in _abort_queue
    poller.poll(50)
  File "/anaconda/lib/python2.7/site-packages/zmq/sugar/poll.py", line 101, in poll
    return zmq_poll(self.sockets, timeout=timeout)
  File "zmq/backend/cython/_poll.pyx", line 115, in zmq.backend.cython._poll.zmq_poll (zmq/backend/cython/_poll.c:1625)
  File "zmq/backend/cython/checkrc.pxd", line 12, in zmq.backend.cython.checkrc._check_rc (zmq/backend/cython/_poll.c:1958)
    PyErr_CheckSignals()
KeyboardInterrupt

In [28]:
plt.figure(figsize=[13,33])
sns.stripplot(y='UNIT', x='date_time', data=df, size=6)
plt.xlim(df.date_time.min(), datetime(2011,5,15,0,0,0))


Out[28]:
(734258.0, 734272.0)

In [ ]: