title: PySpark MLLib: Convert numerical to categorical
body: <p>I got a dataframe from a data repo which has a few features based on date such as </p>
  
  <ul>
  <li>a) the year like 2011 or 2012 in one column, </li>
  <li>b) monthnum like 1 to 12 in another column, </li>
  <li>c) weekdayNum like 1 to 7 in one column and </li>
  <li>d) some other derived columns like IsSunday or IsMonday (represented as 0 or 1) in another column. </li>
  <li>e) with some other numerical features etc. like house sale price. </li>
  </ul>
  
  <pre><code>The types of all these are IntegerType()
  </code></pre>
  
  <p><strong>Question 1</strong>: To train a model should I convert these date related columns to categorical?</p>
  
  <p><strong>Question 2</strong>: How do I do this in PySpark MLLib? Would just casting the data type into StringType() be enough ? So I mean if monthnum is 1 then can I just convert to "1" with the following code? Will the ML algoes take/recognize it as categorical? </p>
  
  <p>Or there is a better way to do it?</p>
  
  <pre><code>from pyspark.sql.types import StringType
  
  df = df.witColumn("MonthNum", df["MonthNum"].cast(StringType()))
  </code></pre>
  
  <p>Thank you so much for helping.</p>