I have a dataframe like this (please discard the first column):
user_id created_at count
1 12136 2017-02-19 4
2 12136 2017-02-16 4
3 12136 2017-02-17 2
4 72349 2017-02-17 8
5 72349 2017-02-19 2
7 72672 2017-02-20 3
8 72672 2017-02-19 2
So, I want to map this values to integer values starting from 0:
12136 -> 0
72349 -> 1
72672 -> 2
And similarly, for the created_at column (starting from the smallest value)
2017-02-16 -> 0
2017-02-17 -> 1
2017-02-19 -> 2
2017-02-20 -> 3
At the end I should have this dataframe (note that 0 values are added for dates where there is no user activity):
user_id created_at count
0 0 4
0 1 2
0 2 4
0 3 0
1 0 0
1 1 8
1 2 2
1 3 0
2 0 0
2 1 0
2 2 2
2 3 3
Also I need to obtain these lists:
label1 = [12136, 72349, 72672]
label2 = ['2017-02-16', '2017-02-17', '2017-02-19', '2017-02-20']
I wonder if there are any methods that could assist me in performing this efficiently?