Last active
March 17, 2021 22:21
-
-
Save mindsdbadmin/2df5186c0306ec05ad94a31c5fcac474 to your computer and use it in GitHub Desktop.
Query split best python workflow
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
# 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