Skip to content

Instantly share code, notes, and snippets.

@mindsdbadmin
Last active March 17, 2021 22:21
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 mindsdbadmin/2df5186c0306ec05ad94a31c5fcac474 to your computer and use it in GitHub Desktop.
Save mindsdbadmin/2df5186c0306ec05ad94a31c5fcac474 to your computer and use it in GitHub Desktop.
Query split best python workflow
# join the items and reviews
result_df = mdsql.query( """
SELECT
category,
sentiment,
sentiment_polarity
FROM gstore_apps_df INNER JOIN gstore_reviews_df
ON gstore_apps_df.app = gstore_reviews_df.app """,
gstore_apps_df = gstore_apps_df,
gstore_reviews_df = gstore_reviews_df )
# group by category and calculate averages
result_df = mdsql.query( """
SELECT
category,
avg(sentiment_polarity) as avg_sentiment_polarity,
avg(sentiment_subjectivity) as avg_sentiment_subjectivity
GROUP BY category
HAVING CAST(avg_sentiment_subjectivity as float) < 0.5
ORDER BY avg_sentiment_polarity DESC
LIMIT 10""",
from= result_df)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment