In [2]:
import pandas as pd
import sqlite3

In [8]:
file = "data/liberia_main.db"
con = sqlite3.connect(file)

In [9]:
query = 'SELECT * FROM scraperlog'

df = pd.read_sql(query, con)

In [10]:
df.columns


Out[10]:
Index([u'id', u'name', u'url_request', u'url_status_code', u'header_len', u'response_len', u'timedate', u'message', u'error'], dtype='object')

In [11]:
df.timedate = pd.to_datetime(df.timedate)

In [12]:
df = df.sort('timedate')

In [14]:
# df.id

In [27]:
df[df.timedate==pd.Timestamp('2015-05-04 22:37:38.890593')]


Out[27]:
name url_request url_status_code header_len response_len timedate message error

In [16]:
dir(pd)


Out[16]:
['Categorical',
 'DataFrame',
 'DateOffset',
 'DatetimeIndex',
 'ExcelFile',
 'ExcelWriter',
 'Expr',
 'Float64Index',
 'Grouper',
 'HDFStore',
 'Index',
 'IndexSlice',
 'Int64Index',
 'LooseVersion',
 'MultiIndex',
 'NaT',
 'Panel',
 'Panel4D',
 'Period',
 'PeriodIndex',
 'Series',
 'SparseArray',
 'SparseDataFrame',
 'SparseList',
 'SparsePanel',
 'SparseSeries',
 'SparseTimeSeries',
 'Term',
 'TimeGrouper',
 'TimeSeries',
 'Timedelta',
 'TimedeltaIndex',
 'Timestamp',
 'WidePanel',
 '__builtins__',
 '__doc__',
 '__docformat__',
 '__file__',
 '__name__',
 '__package__',
 '__path__',
 '__version__',
 '_np_version',
 '_np_version_under1p8',
 '_np_version_under1p9',
 '_period',
 '_sparse',
 '_testing',
 'algos',
 'bdate_range',
 'compat',
 'computation',
 'concat',
 'core',
 'crosstab',
 'cut',
 'date_range',
 'datetime',
 'datetools',
 'describe_option',
 'eval',
 'ewma',
 'ewmcorr',
 'ewmcov',
 'ewmstd',
 'ewmvar',
 'ewmvol',
 'expanding_apply',
 'expanding_corr',
 'expanding_corr_pairwise',
 'expanding_count',
 'expanding_cov',
 'expanding_kurt',
 'expanding_max',
 'expanding_mean',
 'expanding_median',
 'expanding_min',
 'expanding_quantile',
 'expanding_skew',
 'expanding_std',
 'expanding_sum',
 'expanding_var',
 'factorize',
 'fama_macbeth',
 'get_dummies',
 'get_option',
 'get_store',
 'groupby',
 'hashtable',
 'index',
 'infer_freq',
 'info',
 'io',
 'isnull',
 'json',
 'lib',
 'load',
 'lreshape',
 'match',
 'melt',
 'merge',
 'msgpack',
 'notnull',
 'np',
 'offsets',
 'ols',
 'option_context',
 'options',
 'ordered_merge',
 'pandas',
 'parser',
 'period_range',
 'pivot',
 'pivot_table',
 'plot_params',
 'pnow',
 'qcut',
 'read_clipboard',
 'read_csv',
 'read_excel',
 'read_fwf',
 'read_gbq',
 'read_hdf',
 'read_html',
 'read_json',
 'read_msgpack',
 'read_pickle',
 'read_sql',
 'read_sql_query',
 'read_sql_table',
 'read_stata',
 'read_table',
 'reset_option',
 'rolling_apply',
 'rolling_corr',
 'rolling_corr_pairwise',
 'rolling_count',
 'rolling_cov',
 'rolling_kurt',
 'rolling_max',
 'rolling_mean',
 'rolling_median',
 'rolling_min',
 'rolling_quantile',
 'rolling_skew',
 'rolling_std',
 'rolling_sum',
 'rolling_var',
 'rolling_window',
 'save',
 'scatter_matrix',
 'set_eng_float_format',
 'set_option',
 'show_versions',
 'sparse',
 'stats',
 'timedelta_range',
 'to_datetime',
 'to_msgpack',
 'to_pickle',
 'to_timedelta',
 'tools',
 'tseries',
 'tslib',
 'unique',
 'util',
 'value_counts',
 'version',
 'wide_to_long']

In [22]:



Out[22]:
Timestamp('2015-05-04 00:00:00')

In [32]:
df.index.get_loc(pd.to_datetime('2015-05-04 22:37:38.890593'))


---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-32-2da2fbe7db95> in <module>()
----> 1 df.index.get_loc(pd.to_datetime('2015-05-04 22:37:38.890593'))

/home/nathan/.virtualenvs/liberia/lib/python2.7/site-packages/pandas/core/index.pyc in get_loc(self, key, method)
   1435         """
   1436         if method is None:
-> 1437             return self._engine.get_loc(_values_from_object(key))
   1438 
   1439         indexer = self.get_indexer([key], method=method)

/home/nathan/.virtualenvs/liberia/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_loc (pandas/index.c:3824)()

/home/nathan/.virtualenvs/liberia/lib/python2.7/site-packages/pandas/index.so in pandas.index.IndexEngine.get_loc (pandas/index.c:3761)()

KeyError: Timestamp('2015-05-04 22:37:38.890593')

In [ ]: