pandas interview question

Write pandas code that finds each customer's latest order and their 30-day rolling spend.

Hands-on Asked in Machine Learning Engineer · Data Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Sort by customer and date, use groupby().tail(1) (or idxmax) for the latest order, and a time-based rolling window per customer for the 30-day spend. Time-based windows ("30D") need a datetime index within each group.

Keep reading with a membership

The full answer with examples, key points and comparisons is part of the membership, along with every other interview answer, progress tracking and Daily Review. Most-asked answers stay free to read.

See plans and free trial Already a member? Sign in

More pandas questions

← All pandas questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake