title: How to convert column with string type to int form in pyspark data frame?
body: <p>I have dataframe in pyspark. Some of its numerical columns contain <code>nan</code> so when I am reading the data and checking for the schema of dataframe, those columns will have <code>string</code> type.</p>
  <p>How I can change them to int type. I replaced the <code>nan</code> values with 0 and again checked the schema, but then also it's showing the string type for those columns.I am following the below code:</p>
  <pre><code>data_df = sqlContext.read.format(&quot;csv&quot;).load('data.csv',header=True, inferSchema=&quot;true&quot;)
  data_df.printSchema()
  data_df = data_df.fillna(0)
  data_df.printSchema()
  </code></pre>
  <p>my data looks like this:
  <a href="https://i.stack.imgur.com/JslnA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JslnA.png" alt="enter image description here" /></a></p>
  <p>here columns <code>Plays</code> and <code>drafts</code> containing integer values but because of <code>nan</code> present in these columns, they are treated as string type.</p>