Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

user_id retention_1d
001 True

>Solution :

Let us do any

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading