Declarative by design
SQL, XQuery and JSONiq features meet Python. Express grouping, joins, nesting and analytics as one readable query instead of pages of loops.
Integrated query language for Python
The easiest way to work with your data in Python
We have taken the best from query languages such as SQL, XQuery and JSONiq and added it all to Python. Run powerful declarative queries against databases, files, JSON, XML, Pandas data frames and your own collections, all from ordinary Python code.
#coding: pythonql from cust_journey_data import cust_journeys res = [ select (state, len(balance) as n_customers) for cj in cust_journeys let balance = sum(deposits) - sum(withdrawals) where balance > 300 group by new.client_data.address.state as state ]
What PythonQL is
PythonQL lets you query files, databases, XML and JSON data, Pandas data frames and any collection. Install it with a single command, mark a file as PythonQL and start writing queries without changing the way the rest of your project works.
SQL, XQuery and JSONiq features meet Python. Express grouping, joins, nesting and analytics as one readable query instead of pages of loops.
Files, relational databases, XML and JSON documents, Pandas data frames and plain collections are all first class citizens of the same language.
Install with pip, mark a source file with #coding: pythonql, and your existing Python code keeps working exactly as before.
pip install pythonqlpythonql3 for Python 3#coding: pythonqlDetailed demonstration
The web demo walks through four data science scenarios. Each one is broken into small queries you can inspect line by line, and the code behind every result is shown in full.
Use cases
The scenarios are small on purpose. Each one isolates a genuine problem that data scientists run into, then solves it with a short PythonQL query.
Follow every event in a customer relationship and turn heterogeneous timestamps into clean per state analytics.
Open the scenario Scenario 2Assess a new data source quickly, measure how much joins, and decide whether the integration is worth it.
Open the scenario Scenario 3Compare trained models declaratively, group errors by geography and rank which model wins in each segment.
Open the scenario Scenario 4Query a dirty JSON catalog, join it with relational dealer data and build nested objects back out.
Open the scenario