mercredi 1 décembre 2021

Python random sample from dataframe with given characteristics

I have a dataframe df with patients subject_id, including their gender and their age.

I would like to draw a random sample of size n from this dataframe, with the following characteristics:

  • 50% male, 50% female
  • Mean age of 40 years

Any idea how I could accomplish that using python? Thank you!




Aucun commentaire:

Enregistrer un commentaire