Skip to content
Advertisement

Python: Random selection per group

Say that I have a dataframe that looks like:

JavaScript

How could I randomly select one (or more) row for each Group_Id? Say that I want one random draw per Group_Id, I would get:

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement