{"id":311,"date":"2022-01-04T00:00:00","date_gmt":"2022-01-04T00:00:00","guid":{"rendered":"https:\/\/tac.debuzzify.com\/?p=311"},"modified":"2023-06-27T06:29:55","modified_gmt":"2023-06-27T06:29:55","slug":"pandas-sql-query-on-dataframe","status":"publish","type":"post","link":"https:\/\/www.the-analytics.club\/pandas-sql-query-on-dataframe\/","title":{"rendered":"How to Run SQL Queries on Pandas Data Frames?"},"content":{"rendered":"\n

Pandas may be the de-facto standard library for data analysis in Python. Yet, most data scientists are more comfortable with SQL than Pandas data operations.<\/p>\n\n\n\n

At times it may feel like things are easy to do in SQL. Wouldn’t it be great if we had a way to get the best of both worlds?<\/p>\n\n\n\n

It does.<\/p>\n\n\n\n

A wonderful library in the Python ecosystem makes it possible to do this.<\/p>\n\n\n\n

Related: A Better Way to Summarize Pandas Dataframes.<\/a><\/em><\/strong><\/p>\n\n\n\n

Write your first SQL query on a Pandas dataframe with Pandasql<\/h2>\n\n\n\n

Pandasql is an open-source package that lets you run SQL code on pandas data frames. You can check out its repository on GitHub<\/a>.<\/p>\n\n\n\n

You can install Pandasql with PyPI<\/a> as follows.<\/p>\n\n\n\n