I’ve worked with SQL for several years before I started using Pandas in Python. I eventually get used to it but I struggled syntax difference between them when I started.

I want to gather syntax comparison in this article, also as cheat sheet. I’m going to mention to the basic syntax but if there is another example that doesn’t exist in this article, please let me know!

Dataset

I’m going to use this dataset.

import pandas as pd

df_list = [
  ["Lamar Jackson", 23, "Ravens", "QB"]
  , ["Russell Wilson", 31, "Seahawks", "QB"]
  , ["Aaron Donald", 29, "Rams", "DT"]
  , ["Patrick Mahomes", 24, "Chiefs", "QB"]
  , ["Michael Thomas", 27, "Saints", "WR"]
  , ["Christian McCaffrey", 24, "Panthers", "RB"]
  , ["George Kittle", 26, "49ers", "TE"]
  , ["DeAndre Hopkins", 28, "Cardinals", "WR"]
  , ["Stephon Gilmore", 29, "Patriots", "CB"]
  , ["Derrick Henry", 26, "Titans", "RB"]
]
df_columns = ["Name", "Age", "Team", "Position"]
players = pd.DataFrame(data=df_list, columns=df_columns)

#pandas #exploratory-data-analysis #data-science #sql #python

SQL v. Pandas: Basic Syntax Comparison & Cheat Sheet
2.80 GEEK