/pd_join_database.py Secret
Created
November 24, 2019 23:12
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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