title: Select rows from dataframe based on a unique values of other column?
body: <p>One of the column of my dataframe has values shown as below:</p>
  
  <pre><code>air_voice_no_null.loc[:,"host_has_profile_pic"].value_counts(normalize = True)*100
  
  1.0    99.694276
  0.0     0.305724
  Name: host_has_profile_pic, dtype: float64
  </code></pre>
  
  <p>that's 99:1 for each unique value in that column.</p>
  
  <p>I now want to make a new a dataframe, such that it has 60% of 1.0 and 40% of 0.0 from that dataframe along with all rows(of course with less number of rows).</p>
  
  <p>I've tried splitting it using <code>strat</code> function of <code>train_test_split</code> class of <code>sklearn.model_selection</code> as shown below, but with no luck getting dataframes with equal proportions of each unique value.</p>
  
  <pre><code>from sklearn.model_selection import train_test_split
  
  profile_train_x, profile_test_x, profile_train_y, profile_test_y = train_test_split(air_voice_no_null.loc[:,['log_price', 'accommodates', 'bathrooms','host_response_rate', 'number_of_reviews', 'review_scores_rating','bedrooms', 'beds', 'cleaning_fee', 'instant_bookable']],
                                                                                     air_voice_no_null.loc[:,"host_has_profile_pic"],
                                                                                     random_state=42, stratify=air_voice_no_null.loc[:,"host_has_profile_pic"])
  </code></pre>
  
  <p>and this is what the above code resulted in, with no change in number of rows.</p>
  
  <pre><code>print(profile_train_x.shape)
  print(profile_test_x.shape)
  print(profile_train_y.shape)
  print(profile_test_y.shape)
  
  (55442, 10)
  (18481, 10)
  (55442,)
  (18481,)
  </code></pre>
  
  <p>How do I select subset of my dataset with a decreased number of rows, while maintaining appropriate proportions of each class of the <code>host_has_profile_pic</code> variable.</p>
  
  <p>link to the complete dataset: <a href="https://www.kaggle.com/stevezhenghp/airbnb-price-prediction" rel="nofollow noreferrer">https://www.kaggle.com/stevezhenghp/airbnb-price-prediction</a> </p>