I want to calculate binary field churn_flag if user churn the game or he/she is still playing.
I have calculated data max date
max_time = data['time'].max()
Result:
Timestamp('2017-07-12 01:18:50') (future date)
I have calculated each user max date:
data_max_time = pd.DataFrame(data.groupby(['id'])['time'].max()).reset_index() data_max_time.columns = ['id','user_max_time']
Result:
2017-07-11 10:33:11 dtype:datetime64[ns]
I should check if the difference between these two dates longer or shorter than 2 days. I tried to solve it with:
(np.datetime64(final_data['max_time'],'D')-np.datetime64(final_data['user_max_time'],'D'))< (np.timedelta64(2,'D'))
Result:
ValueError: Could not convert object to NumPy datetime
How could I calculate True/False (1/0) field for each user?