In [8]:
import pg8000
import pandas as pd
import matplotlib
import numpy
%matplotlib inline
conn = pg8000.connect(host="training.c1erymiua9dx.us-east-1.rds.amazonaws.com", port=5432, database="training", user="dot_student", password="qgis")

In [9]:
cursor = conn.cursor()

In [10]:
conn.rollback()

In [60]:
df = pd.read_sql("select unique_key,created_date,closed_date from noise_311", conn)

In [61]:
df.head()
df.columns=['unique_key','created_date','closed_date']

In [62]:
df.info()


<class 'pandas.core.frame.DataFrame'>
RangeIndex: 37615 entries, 0 to 37614
Data columns (total 3 columns):
unique_key      37615 non-null int64
created_date    37615 non-null datetime64[ns]
closed_date     37615 non-null datetime64[ns]
dtypes: datetime64[ns](2), int64(1)
memory usage: 881.7 KB

In [63]:
df.head()


Out[63]:
unique_key created_date closed_date
0 28792167 2014-08-31 23:59:00 2014-09-01 03:52:00
1 28789088 2014-08-31 23:56:00 2014-09-01 06:17:00
2 28791854 2014-08-31 23:54:00 2014-09-01 01:29:00
3 28789936 2014-08-31 23:52:00 2014-09-01 02:53:00
4 28789931 2014-08-31 23:47:00 2014-09-01 01:06:00

In [64]:
df['opentime'] = df['closed_date']-df['created_date']

In [65]:
df.index=df['opentime']

In [58]:
df[]


Out[58]:
array([[<matplotlib.axes._subplots.AxesSubplot object at 0x116e2a6a0>]], dtype=object)

In [ ]: