I have a dataset which includes periods, customer and the amount sold. What I'm trying to determine is for customers who were sold to in the period 1 less than the current period, has that customer been sold to in this period (e.g. has a customer stopped purchasing all together in the most recent period):
My dataset looks like:
PERIOD CUSTOMER AMOUNTSOLD
0 2020-08 C1 1000
1 2020-08 C2 1000
2 2020-08 C3 1000
3 2020-09 C1 1000
4 2020-09 C2 1000
I've thought about splitting the dataset into different dataframes dependent on the period, then checking if the the customer exists in the corresponding periods dataframe, but I don't think this would be a particularly efficient way to do it.
From Manakins comment, my expected output would be:
CUSTOMER EXISTS IN PREVIOUS PERIOD AND CURRENT PERIOD
C1 Y
C2 Y
C3 N
Help would be very much appreciated,
Thank you