title: python pandas dataframe create bins only for data in threshold
body: <p>In a python pandas dataframe "df", I have the following three columns:</p>
  
  <pre><code>song_id | user_id | play_count
  </code></pre>
  
  <p>play_count = how many times a user listened to a song</p>
  
  <p>I am trying to add a column "rating" to this table based on play count. 
  For example, if play_count =2, the rating will be low like "1". </p>
  
  <p>First, I need to establish the rating threshold for my 1-10 rating system.</p>
  
  <pre><code>df.play_count.describe()
  count    393727.000000
  mean          2.567627
  std           4.822111
  min           1.000000
  25%           1.000000
  50%           1.000000
  75%           2.000000
  max         771.000000
  Name: play_count, dtype: float64
  </code></pre>
  
  <p>Most of the play_counts are between 1 and 200:</p>
  
  <pre><code>pd.value_counts(pd.cut(df.play_count, bins = 10))
  (0.23, 78]    393576
  (78, 155]        129
  (155, 232]        13
  (232, 309]         6
  (309, 386]         2
  (694, 771]         1
  (617, 694]         0
  (540, 617]         0
  (463, 540]         0
  (386, 463]         0
  dtype: int64
  </code></pre>
  
  <p>I would like to create 10 buckets, with the last bucket being that if the play_count is above 200, the song has a rating of "10". So I need to establish the thresholds of the other 9 buckets. </p>
  
  <p>Unfortunately, this does not work:</p>
  
  <pre><code>pd.value_counts(pd.cut(df[['play_count'] &lt; 200]], bins = 9))
  f = df[df['play_count'] &lt; 200].hist()
  </code></pre>