I want to create a column churn
as shown.
The code should group and compare each year's column Col
and assign 0 if it finds Col
value in next year.
In this example 3rd row is missing from 2017. Hence assigning 1.
How do I do this in pandas?
State ID Col Year cost Churn
CT 123 M 2016 10 0
CT 123 C 2016 15 0
CT 123 A 2016 10 1
CT 123 C 2016 20 0
CT 123 M 2017 10 0
CT 123 C 2017 15 0