Skip to content

danielunderwood/sqldf

Repository files navigation

sqldf

Tests

Ever wish you could query pandas DataFrames with SQL like this?

df = pd.DataFrame(...)
sqldf.query_df(df, """
SELECT *, sum(b)
WHERE a > 5
GROUP BY b
""")

Well now you can with sqldf!

Currently Supported

  • SELECT
  • WHERE
    • =, !=, >, >=, <, <=, IN, NOT IN

Not (Yet) Supported

  • SELECT ... AS
  • FROM
  • GROUP BY
  • JOIN
  • WHERE ... LIKE
  • ORDER BY

How it Works

A PEG grammar is defined in sqldf/sql.gram that is passed through pegen to generate the parser in sqldf/parser.py that parses the SQL and generates objects (currently dictionaries). The generated objects are then processed to build up the relevant pandas calls to return the processed DataFrame.

About

Query pandas DataFrames using SQL

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published