How to use LAST function

 We have grocery purchase data for this month and one of the fast moving item is eggs. We have a list of customers who buy eggs regularly and we want know when was the last date customers bought eggs this month.




We can see that last date of buying eggs for customers Patel, Raval and Shah was 21,17 and 29

But how to run a code that can give this information?

eggs.groupby('customer').Date.last()

Here, eggs is our dataframe, customer and Date are columns


This is a very useful function and it is helpful in getting a list of customers who have not bought eggs for certain no of days so they can be contacted by a campaign
.

No comments:

Post a Comment

Complex query example

Requirement:  You are given the table with titles of recipes from a cookbook and their page numbers. You are asked to represent how the reci...