I have the below sql query. I should achieve the same logic in python
"count(ticket_id)*100 from interactions
where ticket_status='PENDING'/count(ticket_id) where ticket_status in ('COMPLETED','CREATED','IN-PROGRESS')"
Any help would be appreciatable!!
CodePudding user response:
if you have a dataframe named interactions
for this part of query you mentioned since it seems valid till there
count(ticket_id)*100 from interactions where ticket_status='PENDING'
python part
interactions[interactions['ticket_status'=='PENDING']].count()*100
CodePudding user response:
Your query looks odd but is this what you are looking for?
out = (interactions.loc[interactions['ticket_status'] == 'PENDING', 'ticket_id'].count() * 100 /
interactions.loc[interactions['ticket_status'].isin(('COMPLETED','CREATED','IN-PROGRESS')), 'ticket_id'].count()
)
