title: Pyspark data frame Converting false and true to 0 and 1
body: <p>I have a data frame in Pyspark </p>
  
  <pre><code>df.show()
  
  
  +-----+-----+
  |test1|test2|
  +-----+-----+
  |false| true|
  | true| true|
  | true|false|
  |false| true|
  |false|false|
  |false|false|
  |false|false|
  | true| true|
  |false|false|
  +-----+-----+
  </code></pre>
  
  <p>I want to convert all the <code>false</code> values in data frame to <code>0</code> and <code>true to 1</code>.</p>
  
  <p>I am doing like below</p>
  
  <pre><code>df1 = df.withColumn('test1', F.when(df.test1 == 'false', 0).otherwise(1)).withColumn('test2', F.when(df.test2 == 'false', 0).otherwise(1))
  </code></pre>
  
  <p>I got my result. But I think there might be a better way to do this.</p>