0

How to convert my sql query to data frame

column names of PRODUCT data frame user_id,status,actual_cost,selling_price

Mysql query

SELECT user_id, count(*) as Count FROM PRODUCT WHERE status = 'SOLD' AND actual_cost>50 AND selling_price>60
group by user_id

Disclaimer. Please don't tell to use pymsql or pandassql since groupby is very large >50K rows, Data base wont have that TTL

1 Answer 1

1

Something like

PRODUCT.query("status == 'SOLD' 
    and actual_cost > 50 
    and selling_price > 60").groupby('user_id').size().reset_index(name='Count')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.