Fill in a column grouped by condition

I have table:

user_id days_since_install
001 0
001 1
001 1

It is necessary to check if there is 1 in the column "days_since_install" in grouping by "user_id" and fill in True in the column "retention_1d" otherwise False.

The resulting table should look like this:

user_id retention_1d
001 True

>Solution :

Let us do any

df.groupby('user_id')['days_since_install'].any().reset_index()

Leave a Reply