title: get datatype of column using pyspark
body: <p>We are reading data from MongoDB <code>Collection</code>. <code>Collection</code> column has two different values (e.g.: <code>(bson.Int64,int) (int,float)</code> ).</p>
  
  <p>I am trying to get a datatype using pyspark.</p>
  
  <p>My problem is some columns have different datatype.</p>
  
  <p>Assume <code>quantity</code> and <code>weight</code> are the columns </p>
  
  <pre><code>quantity           weight
  ---------          --------
  12300              656
  123566000000       789.6767
  1238               56.22
  345                23
  345566677777789    21
  </code></pre>
  
  <p>Actually we didn't defined data type for any column of mongo collection.</p>
  
  <p>When I query to the count from <code>pyspark dataframe</code><br/></p>
  
  <pre><code>dataframe.count()
  </code></pre>
  
  <p>I got exception like this</p>
  
  <pre><code>"Cannot cast STRING into a DoubleType (value: BsonString{value=&amp;apos;200.0&amp;apos;})"
  </code></pre>