samedi 15 décembre 2018

How to obtain a balanced dataframe in Python

I have a DataFrame containing 4000 rows. I'd like to select 20 random rows from this dataframe.

The new DataFrame must be balanced. That means that I have an attribute called default that can take two values, yes or no. Therefore, the new balanced DataFrame must contain 10 samples with yes and 10 samples with no.

Can you help me?




Aucun commentaire:

Enregistrer un commentaire