pandasql Documentation

repository·master·Indexed 23 days ago

https://github.com/yhat/pandasql

A library that allows users to query pandas DataFrames using standard SQLite syntax via the sqldf function, providing a SQL-based interface for data manipulation.

Tokens
247
Snippets
2
Records
3
Agent score
30%

What's inside pandasql

  1. Query pandas DataFrames with SQLite syntax

    master
    You can query any pandas DataFrame as if it were a regular SQL table. pandasql automatically detects DataFrames in your environment. The library uses SQLite syntax, supporting standard operations like SELECT, LIMIT, JOIN, GROUP BY, and aggregations.
  2. Use the sqldf function to query DataFrames

    master

    The primary interface for pandasql is the sqldf function. It accepts two parameters:

    1. A SQL query string.
    2. A dictionary representing the environment (typically locals() or globals()) where the DataFrames are defined.

    To avoid passing the environment dictionary every time, it is a common pattern to define a helper function using a lambda expression.

    from pandasql import sqldf
    pysqldf = lambda q: sqldf(q, globals())