In [1]:
import pandas as pd
from sqlalchemy import create_engine # database connection
sql = create_engine('sqlite:///data/zodiac.sqlite')
# look up plotting: http://pandas.pydata.org/pandas-docs/stable/visualization.html
In [2]:
df = pd.read_sql_query('SELECT * FROM horoscopes LIMIT 5', sql)
df.head()
Out[2]:
In [21]:
df = pd.read_sql_query('select count(*) as occurence, "keyword", "interp" from horoscopes group by "keyword" having occurence >= 1 order by occurence desc', sql)
In [6]:
import matplotlib
import matplotlib.pylab as plt
matplotlib.style.use('ggplot')
%matplotlib inline
In [27]:
plot = df.plot(kind='hist', orientation='vertical', cumulative=False, bins=20, logy=True)
fig = plot.get_figure()
fig.savefig("keyword_occurence.png", dpi=1200)
In [50]:
df = pd.read_sql_query('SELECT count(*),rating FROM horoscopes group by rating', sql)
df.hist()
Out[50]:
In [51]:
df
Out[51]:
In [ ]: