Skip to content

Instantly share code, notes, and snippets.

@jefferythewind
Created October 6, 2016 12:00
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 jefferythewind/62e31a430f08a9cd00ee167522097902 to your computer and use it in GitHub Desktop.
Save jefferythewind/62e31a430f08a9cd00ee167522097902 to your computer and use it in GitHub Desktop.
sql_query = """
SELECT main_user.id, age, gender, race, height, weight, drinks, tobacco, illegal_drugs,
prescription_drugs, network_size, likes, media, follows, followed_by, comments
FROM main_user
JOIN main_survey ON main_user.id = main_survey.id
JOIN (
select
sum(likes) as likes,
sum(comments) as comments,
survey_id as id
from
main_instagrammedia
group by
survey_id
) media_totals
ON main_survey.id = media_totals.id;
"""
arradata = pd.read_sql(sql_query, engine)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment