AnalystPath

Flagged Support Messages

PandasEasyJunior level~10 min

Problem

You are given a DataFrame `support_messages` (CSV `support_messages.csv`) with columns message_id and body. A message is flagged for review when it breaks any of these limits: the body is longer than 60 characters, it contains more than 3 tilde characters (`~`), or it contains more than 3 asterisk characters (`*`). Return the `message_id` of every flagged message, ordered ascending.

Input data

Example rows — the live problem includes the full dataset.

support_messages
message_idbody
1Order delayed, please help ~ contact ~ escalate ~ refund ~ urgent ~ thanks
2Tracking ref *AB12 and ref *CD34 both stuck at depot
3My parcel never arrived even though the app said delivered yesterday
4Codes *X1 *X2 *X3 *X4 *X5 all expired before I could redeem any of them at checkout
5Need help with login it keeps logging me out after a few seconds every time

Expected output

Your answer should return 7 rows with the columns message_id.

Starter code (Pandas (Python))

import pandas as pd

def flagged_support_messages(support_messages) -> pd.DataFrame:
    # Your code here
    return support_messages

Solve this Pandas question free

Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related Pandas questions