← Visa Interview Insights

Visa·Data Scientist·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Technical round for a Data Scientist role at Visa where they gave you a transactions dataset and made you solve the same problem twice, once in pandas and once in SQL. Pretty straightforward if you're comfortable with both, but the dual-format requirement caught me slightly off guard.

Questions Asked (1)

Q1

Given a transactions table, calculate each user's total amount spent in 2023, excluding negative amounts (refunds). Return user_id and total_spent sorted descending. Solve it first in Python using pandas, then rewrite the same logic in SQL using a CTE and GROUP BY.

Product Analytics & MetricsData Modeling
Author's notes

The pandas part was fine, filter by year, drop negatives, groupby user_id, sum, sort.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the schema and business rules (e.g., date range, refund handling), then implement the pandas solution using filtering, grouping, and aggregation, and finally translate the same logic into a SQL query with a CTE and GROUP BY. Emphasize that both solutions should produce identical results and discuss performance considerations.

Pro tip: Mention that you would validate the results by cross-checking the pandas and SQL outputs, and discuss how you'd handle edge cases like users with no transactions or null amounts.

1. Clarify requirements and schema

Ask about the table structure (columns, data types) and confirm the definition of 'total amount spent' (e.g., sum of positive amounts only, date range inclusive).

2. Implement pandas solution

Load data into a DataFrame, filter for 2023 and positive amounts, group by user_id, sum the amount, and sort descending.

3. Implement SQL solution

Write a CTE to filter transactions for 2023 and positive amounts, then select user_id and SUM(amount) grouped by user_id, ordered descending.

4. Validate and compare

Run both solutions on sample data and ensure they match; discuss potential discrepancies and how to resolve them.

5. Discuss performance and edge cases

Talk about indexing, handling nulls, users with no transactions, and scalability for large datasets.

Key Points to Mention

  • Filtering for the year 2023 using date functions (e.g., dt.year in pandas, EXTRACT(YEAR FROM date) in SQL).
  • Excluding negative amounts (refunds) by filtering amount > 0.
  • Grouping by user_id and summing the amount.
  • Sorting the results in descending order of total_spent.
  • Using a CTE in SQL for readability and logical separation.
  • Ensuring consistency between pandas and SQL implementations.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.