FastPrepConditional Group Aggregation
Problems/Conditional Group Aggregation

Conditional Group Aggregation

Stripe logoStripeNEW GRADOA

Updated Nov 2026

QuestionConstraints

Problem statement

Source note: Reported in a Stripe online assessment for new-grad PhD Machine Learning Engineer roles. The report describes a pandas ETL task with grouping, totals, conditional counts and filters in several steps. It does not share the tables, the conditions or the expected output. We chose the samples layout, the filtering rules, the thresholds, the ordering and the cases, as one reading of the task. May 6, 2026 is the report date, and the exact date of the assessment is unknown. The SQL versions are alternatives to the reported pandas task.

Group rows, compute conditional counts and aggregate values, then apply filters to the grouped result.

Interpretation

For this exercise, assume the supplied samples table contains row_id, cohort, value and quality.

  1. Keep only rows whose value >= 0 and whose quality is exactly ok or bad.
  2. Group the retained rows by cohort. Count all retained rows as row_count, count only retained ok rows as ok_count, and sum retained value as total_value. Identical values in different rows count separately.
  3. Return only cohorts with row_count >= 3, ok_count >= 2 and total_value >= 100.
  4. Return columns cohort, row_count, ok_count, total_value in that order, with rows sorted by cohort in ascending order. If no cohort qualifies, return these columns and no rows.

Table schema

MySQLPostgreSQLPandas

Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.

samples

ColumnTypeNullableDescription
row_idPKIntegerNo—
cohortTextNo—
valueIntegerNo—
qualityTextNo—

Expected result

Your query or function must return these columns.

ColumnTypeNullableDescription
cohortTextNo—
row_countIntegerNo—
ok_countIntegerNo—
total_valueIntegerNo—

Row order: must match exactly. Numeric tolerance: 0.

Constraints

  • There are 0 to 2,000 input rows. All fields are non-null, and row_id values are unique.
  • Each value is an integer between -1,000 and 1,000. Cohort values contain only lowercase English letters or only uppercase English letters per case; quality is case-sensitive text.
  • The input may contain groups that have no qualifying rows. Return one row per qualifying cohort.

More Stripe Online Assessment questions

  • Asynchronous Event ProcessingOA · Seen Nov 2026
  • Maximum Game Score with Fixed Forward JumpsOA · Seen Nov 2026
  • Reliable LLM Call with Independent Retry BudgetsOA · Seen Nov 2026
  • Request Routing SystemOA · Seen Nov 2026
  • Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
  • Chat Billing CalculationOA · Seen Nov 2026
  • Deployment Window SchedulerOA · Seen Nov 2026
  • Subscription and Usage-Based Billing CalculatorOA · Seen Nov 2026
  • Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
  • Incident MonitorOA · Seen Nov 2026

Interview reports that mention this question

  • Stripe OA: What It Tests (2026)

Stripe interview experiences

  • Stripe New Grad SWE OA and Phone Screen: 2 Experiences
  • Stripe Experienced SWE OA and Onsite Questions: 3 Experiences
  • Stripe SWE Intern Linked Merchants Team Screen: 1 Experience
  • Stripe SWE Onsite over Two Days: 1 Experience
  • Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
All Stripe interview questionsSee Stripe hiring insights