title: how to split value in dataframe and replace with another value
body: <p>Dataframe:</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  d = {'A': ['B_502_ZZZ_01', 'B_400__01']}
  df = pd.DataFrame(data=d)
  </code></pre>
  <p>I tried:</p>
  <pre class="lang-py prettyprint-override"><code>def f(x):
   x = x.split('_')[2]
   if x=='':
     x = x.replace('', 'ZZZ') 
   return x
  else: 
   return x
  df['A'].apply(f)
  </code></pre>
  <p>Output required full value like not only 2nd position. I can split 3rd position in another column but I want position changes at that location directly.</p>
  <pre><code>['B_502_ZZZ_01', 'B_400_ZZZ_01'] 
  </code></pre>