Skip to content

Instantly share code, notes, and snippets.

@j-bennet
Created November 24, 2019 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j-bennet/ca2a85974c898707c02e3155308e0348 to your computer and use it in GitHub Desktop.
Save j-bennet/ca2a85974c898707c02e3155308e0348 to your computer and use it in GitHub Desktop.
# don't do this
t1 = pd.read_sql_query("select t1.field1, t1.field2 from table1 t1")
t2 = pd.read_sql_query("select t2.field1, t2.field2 from table2 t2")
df = t1.merge(t2, how="inner", on="field1")
# do this
pd.read_sql_query("select t1.field1, t1.field2, t2.field2 "
"from table1 t1"
"join table2 t2 on t1.field1 = t1.field1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment