This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| pd.set_printoptions(max_columns=25) | |
| from pandasql import sqldf | |
| from pandasql import load_meat, load_births | |
| meat = load_meat() | |
| births = load_births() | |
| print meat.head() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################# | |
| # SQL FUNCTIONS | |
| # e.g. `RANDOM()` | |
| ################################################# | |
| q = """SELECT | |
| * | |
| FROM | |
| meat | |
| ORDER BY RANDOM() | |
| LIMIT 10;""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| q = """ | |
| SELECT | |
| date | |
| , beef | |
| , veal | |
| , pork | |
| , lamb_and_mutton | |
| FROM | |
| meat | |
| WHERE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # joining meats + births on date | |
| q = """ | |
| SELECT | |
| m.date | |
| , b.births | |
| , m.beef | |
| FROM | |
| meat m | |
| INNER JOIN | |
| births b |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def pysqldf(q): | |
| return sqldf(q, globals()) | |
| q = """ | |
| SELECT | |
| * | |
| FROM | |
| births | |
| LIMIT 10;""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # births per year | |
| q = """ | |
| SELECT | |
| strftime("%Y", date) | |
| , SUM(births) | |
| FROM births | |
| GROUP BY 1 | |
| ORDER BY 1; | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| q = """ | |
| SELECT | |
| * | |
| FROM | |
| meat | |
| LIMIT 10;""" | |
| print sqldf(q, locals()) | |
| # date beef veal pork lamb_and_mutton broilers other_chicken turkey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from pandas.io import sql | |
| help(sql) | |
| # Help on module pandas.io.sql in pandas.io: | |
| # NAME | |
| # pandas.io.sql | |
| # FILE | |
| # /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/sql.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| !!! | |
| %html | |
| %head | |
| %title= full_title(yield(:title)) | |
| = render 'layouts/stylesheets' | |
| = javascript_include_tag "application" | |
| = csrf_meta_tags | |
| %body | |
| #wrapper | |
| = render 'layouts/header' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var app = require('express')() | |
| , server = require('http').createServer(app) | |
| , io = require('socket.io').listen(server) | |
| , Series = require('./series').Series; | |
| app.use(require('connect').static(__dirname + '/public')) | |
| server.listen(8080); | |
| app.get('/', function (req, res) { | |
| res.sendfile(__dirname + '/index.html'); |