Skip to content

Instantly share code, notes, and snippets.

@mindsdbadmin
mindsdbadmin / Query split python workflow.py
Last active March 17, 2021 22:21
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,
# 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,
# load gstore reviews data
gstore_reviews_df = pd.read_csv("https://tinyurl.com/gstorereviewscsv")
# Importing in memory SQL engine as mdsql
# in the next couple of days you will import as follows
# - import modin.experimental.sql as mdsql
# For now you can pip install the sql engine 'pip install pdsql' and include it as follows:
from dfsql import sql_query
import modin.sql as mdsql
mdsql.query = sql_query
# You can then define the query that you want to perform
@mindsdbadmin
mindsdbadmin / pandas select and filter .py
Last active March 17, 2021 00:47
Pure Pandas select and filter
# Select columns
result_df1 = gstore_apps_df.loc[,: ['App','Category',Rating']]
# From the resulting dataframe filter where Price = 0
result_df = result_df1['Price'] == 0
import modin.pandas as pd
# read google play app store list from csv
gstore_apps_df = pd.read_csv("https://tinyurl.com/googleplaystorecsv")
import modin.pandas as pd
gstore_apps_df = pd.read_csv("https://tinyurl.com/googleplaystorecsv")
@mindsdbadmin
mindsdbadmin / clickhouse-conf-v3.json
Created October 26, 2020 10:15
Configuration for AI Tables in Clickhouse
{
"api": {
"http": {
"host": "0.0.0.0",
"port": "47334"
},
"mysql": {
"host": "127.0.0.1",
"password": "",
"port": "47335",
@mindsdbadmin
mindsdbadmin / mariadb-conf-v3.json
Last active October 26, 2020 10:13
Configuration for AI Tables in MariaDB
{
"api": {
"http": {
"host": "0.0.0.0",
"port": "47334"
},
"mysql": {
"host": "127.0.0.1",
"password": "",
"port": "47335",
SELECT price AS predicted,
price_confidence AS confidence,
price_explain AS info
FROM mindsdb.used_cars_model
WHERE model = "a1"
AND mileage = 122946
AND transmission = "manual"
AND fueltype = "petrol"
AND mpg = "35.4"
AND enginesize = 1.4