CoCalc Public Filessupport / 2016-05-07-151156-pandasql.sagewsOpen in with one click!
Author: William A. Stein
Description: Jupyter notebook support/2015-06-04-141749-bokeh.ipynb
from pandasql import sqldf pysqldf = lambda q: sqldf(q, globals())
from pandasql import sqldf
Help on function sqldf in module pandasql.sqldf: sqldf(q, env, inmemory=True) query pandas data frames using sql syntax Parameters ---------- q: string a sql query using DataFrames as tables env: locals() or globals() variable environment; locals() or globals() in your function allows sqldf to access the variables in your python environment dbtype: bool memory/disk; default is in memory; if not memory then it will be temporarily persisted to disk Returns ------- result: DataFrame returns a DataFrame with your query's result Examples -------- >>> import pandas as pd >>> df = pd.DataFrame({ "x": range(100), "y": range(100) }) >>> from pandasql import sqldf >>> sqldf("select * from df;", globals()) >>> sqldf("select * from df;", locals()) >>> sqldf("select avg(x) from df;", locals())