Last active
March 17, 2021 22:23
-
-
Save mindsdbadmin/08fb09e26f234f40027cdb01b11f9f08 to your computer and use it in GitHub Desktop.
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
# Single query with join and group by | |
sql_str = """ | |
SELECT | |
category, | |
avg(sentiment_polarity) as avg_sentiment_polarity, | |
avg(sentiment_subjectivity) as avg_sentiment_subjectivity | |
FROM ( | |
SELECT | |
category, | |
CAST(sentiment as float) as sentiment, | |
CAST(sentiment_polarity as float) as sentiment_polarity | |
FROM gstore_apps_df | |
INNER JOIN gstore_reviews_df | |
ON gstore_apps_df.app = gstore_reviews_df.app | |
) sub | |
GROUP BY category | |
HAVING avg_sentiment_subjectivity < 0.5 | |
ORDER BY avg_sentiment_polarity DESC | |
LIMIT 10 | |
""" | |
# Run query using apps and reviews dataframes, | |
# NOTE: that you simply pass the names of the tables in the query as arguments | |
result_df = mdsql.query( sql_str, | |
gstore_apps_df = gstore_apps_df, | |
gstore_reviews_df = gstore_reviews_df) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment