0

I have a data frame contains one-month data.

   login_date    user_id
0  2019-12-22   432
1  2019-12-22   432
2  2019-12-22   339
3  2019-12-23   438
4  2019-12-23   432
5  2019-12-23   431
6  2019-12-25   339
7  2019-12-25   438
8  2019-12-25   432
9  2019-12-25   432
10  2019-12-25   339
11  2019-12-26   438
12  2019-12-29   339
13  2019-12-31   432
14  2019-12-31   432
15  2019-12-31   453

I am trying to calculate count the user's login days of the month.

Expected output:

   user_id login_days
0  432     4
1  339     3
2  438     3
3  431     1
4  453     1


I tried using the below code.

df.groupby(df['user_id']).count()

But I am not getting what I want. If someone can help, it would be grateful.

xcen
  • 652
  • 2
  • 6
  • 22

0 Answers0