title: python-pandas: new column based on index?
body: <p>I have a df similar to the one below:</p>
  <pre><code>        name    age sex
     1    john    12  m
     2    mary    13  f
     3    joseph  12  m
     4    maria   14  f
  </code></pre>
  <p>How can I make a new column based on the index? for example for index 1 and 2, i want them to have the label <code>1</code> and for index 3 and 4, i want them to be labeled <code>2</code>, like so:</p>
  <pre><code>        name    age sex label
     1    john    12  m   cluster1
     2    mary    13  f   cluster1
     3    joseph  12  m   cluster2
     4    maria   14  f   cluster2
  </code></pre>
  <p>Should i use something like <code>(df.index.isin([1, 2])) == 'cluster1'</code>? I think it's not possible to do <code>df['target'] = (df.index.isin([1, 2])) == 'cluster1</code> assuming that <code>label</code> doesn't exist in the beginning.</p>