title: Casting a new derived column in a DataFrame from boolean to integer
body: <p>Suppose I have a DataFrame <code>x</code> with this schema:</p>
  
  <pre><code>xSchema = StructType([ \
      StructField("a", DoubleType(), True), \
      StructField("b", DoubleType(), True), \
      StructField("c", DoubleType(), True)])
  </code></pre>
  
  <p>I then have the DataFrame:</p>
  
  <pre><code>DataFrame[a :double, b:double, c:double]
  </code></pre>
  
  <p>I would like to have an integer derived column. I am able to create a boolean column:</p>
  
  <pre><code>x = x.withColumn('y', (x.a-x.b)/x.c &gt; 1)
  </code></pre>
  
  <p>My new schema is:</p>
  
  <pre><code>DataFrame[a :double, b:double, c:double, y: boolean]
  </code></pre>
  
  <p>However, I would like column <code>y</code> to contain 0 for False and 1 for True.</p>
  
  <p>The <code>cast</code> function can only operate on a column and not a <code>DataFrame</code> and the <code>withColumn</code> function can only operate on a <code>DataFrame</code>. How to I add a new column and cast it to integer at the same time? </p>