title: Replace Special characters of column names in Spark dataframe
body: <p>I have my input <code>spark-dataframe</code> named <code>df</code> as,</p>
  
  <pre><code>+---------------+----------------+-----------------------+
  |Main_CustomerID|126+ Concentrate|2.5 Ethylhexyl_Acrylate|
  +---------------+----------------+-----------------------+
  |         725153|             3.0|                    2.0|
  |         873008|             4.0|                    1.0|
  |         625109|             1.0|                    0.0|
  +---------------+----------------+-----------------------+
  </code></pre>
  
  <p>I need to remove the special characters from the column names of <code>df</code> like following,</p>
  
  <ul>
  <li><p>Remove <code>+</code> </p></li>
  <li><p>Replace space as <code>underscore</code></p></li>
  <li>Replace <code>dot</code> as <code>underscore</code></li>
  </ul>
  
  <p>So my <code>df</code> should be like   </p>
  
  <pre><code>+---------------+---------------+-----------------------+
  |Main_CustomerID|126_Concentrate|2_5_Ethylhexyl_Acrylate|
  +---------------+---------------+-----------------------+
  |         725153|            3.0|                    2.0|
  |         873008|            4.0|                    1.0|
  |         625109|            1.0|                    0.0|
  +---------------+---------------+-----------------------+
  </code></pre>
  
  <p>Using Scala, I have achieved this by,</p>
  
  <pre><code>var tableWithColumnsRenamed = df
  
  for (field &lt;- tableWithColumnsRenamed.columns) {
        tableWithColumnsRenamed = tableWithColumnsRenamed
          .withColumnRenamed(field, field.replaceAll("\\.", "_"))
      }
  for (field &lt;- tableWithColumnsRenamed.columns) {
        tableWithColumnsRenamed = tableWithColumnsRenamed
          .withColumnRenamed(field, field.replaceAll("\\+", ""))
      }
  for (field &lt;- tableWithColumnsRenamed.columns) {
        tableWithColumnsRenamed = tableWithColumnsRenamed
          .withColumnRenamed(field, field.replaceAll(" ", "_"))
      }
  
  df = tableWithColumnsRenamed
  </code></pre>
  
  <p>When I used,</p>
  
  <pre><code>for (field &lt;- tableWithColumnsRenamed.columns) {
        tableWithColumnsRenamed = tableWithColumnsRenamed
          .withColumnRenamed(field, field.replaceAll("\\.", "_"))
      .withColumnRenamed(field, field.replaceAll("\\+", ""))
      .withColumnRenamed(field, field.replaceAll(" ", "_"))
      }
  </code></pre>
  
  <p>I got the first column name as <code>126 Concentrate</code> instead of getting <code>126_Concentrate</code></p>
  
  <p>But I don't prefer 3 for loops for this replacement. Can I get the solution?</p>