title: different substring for each row based on condition
body: <p>How do one add a different substring to each row based on a condition in pandas?</p>
  <p>Here is a dummy dataframe that I created:</p>
  <pre><code>import numpy as np
  import pandas as pd
  np.random.seed(1)
  df = pd.DataFrame(np.random.randint(0,5,size=(5, 2)))
  df.columns = ['A','B']
  </code></pre>
  <p>If I replace the rows in <code>B</code>, with a string <code>YYYY</code> for those rows which have the value in <code>A</code> less then 5, then I would do it this way:</p>
  <pre><code>df.loc[df['A'] &lt; 2, 'B'] = 'YYYY'
  </code></pre>
  <p>This is the current output of original df:</p>
  <pre><code>   A  B
  0  3  4
  1  0  1
  2  3  0
  3  0  1
  4  4  4
  </code></pre>
  <p>Of replaced df:</p>
  <pre><code>   A     B
  0  3     4
  1  0  YYYY
  2  3     0
  3  0  YYYY
  4  4     4
  </code></pre>
  <p>What I instead want is:</p>
  <pre><code>   A     B
  0  3     4
  1  0    1_1
  2  3     0
  3  0    1_2
  4  4     4
  </code></pre>