title: Replace string in PySpark
body: <p>I am having a dataframe, with numbers in European format, which I imported as a String. Comma as decimal and vice versa -</p>
  <pre><code>from pyspark.sql.functions import regexp_replace,col
  from pyspark.sql.types import FloatType
  df = spark.createDataFrame([('-1.269,75',)], ['revenue'])
  df.show()
  +---------+
  |  revenue|
  +---------+
  |-1.269,75|
  +---------+
  df.printSchema()
  root
   |-- revenue: string (nullable = true)
  </code></pre>
  <p><strong>Output desired:</strong>
  df.show()</p>
  <pre><code>+---------+
  |  revenue|
  +---------+
  |-1269.75|
  +---------+
  df.printSchema()
  root
   |-- revenue: float (nullable = true)
  </code></pre>
  <p>I am using function <code>regexp_replace</code> to first <em>replace dot with empty space</em> - then <em>replace comma with empty dot</em> and finally cast into floatType.</p>
  <pre><code>df = df.withColumn('revenue', regexp_replace(col('revenue'), &quot;.&quot;, &quot;&quot;))
  df = df.withColumn('revenue', regexp_replace(col('revenue'), &quot;,&quot;, &quot;.&quot;))
  df = df.withColumn('revenue', df['revenue'].cast(&quot;float&quot;))
  </code></pre>
  <p>But, when I attempt replacing below, I get empty string. Why?? I was expecting <code>-1269,75</code>.</p>
  <pre><code>df = df.withColumn('revenue', regexp_replace(col('revenue'), &quot;.&quot;, &quot;&quot;))
  +-------+
  |revenue|
  +-------+
  |       |
  +-------+
  </code></pre>