title: Taking a proportion of a dataframe based on column values
body: <p>I have a Pandas dataframe with ~50,000 rows and I want to randomly select a proportion of rows from that dataframe based on a number of conditions. Specifically, I have a column called 'type of use' and, for each field in that column, I want to select a different proportion of rows.</p>
  
  <p>For instance:</p>
  
  <pre><code>df[df['type of use'] == 'housing'].sample(frac=0.2)
  </code></pre>
  
  <p>This code returns 20% of all the rows which have 'housing' as their 'type of use'. The problem is I do not know how to do this for the remaining fields in a way that is 'idiomatic'. I also do not know how I could take the result from this sampling to form a new dataframe.</p>