title: I want to change a column of month numbers in a dataframe to month name (pyspark)
body: <p>I have a column of month numbers in a dataframe and want to change it to month name, so I used this:    </p>
  
  <pre><code>df['monthName'] = df['monthNumber'].apply(lambda x: calendar.month_name[x]) 
  </code></pre>
  
  <p>But it throws me the following error: </p>
  
  <p>TypeError: 'Column' object is not callable</p>
  
  <p>Please suggest me what are the ways to resolve this. I am new to python and spark</p>
  
  <p>Edit1: I m using Spark 2.1.1 and Python 2.7.6</p>
  
  <p>This is my code for Airline data Analysis. </p>
  
  <pre><code>df_withDelay = df_mappedCarrierNames.filter(df_mappedCarrierNames.ArrDelay &gt; 0)
  sqlContext.registerDataFrameAsTable(df_withDelay,"SFO_ArrDelayAnalysisTable")
  df_SFOArrDelay = sqlContext.sql \
                        ("select sfo.Month, sum(sfo.ArrDelay) as TotalArrivalDelay \
                        from SFO_ArrDelayAnalysisTable sfo \
                        where (sfo.Dest = 'SFO') \
                        group by sfo.Month")
  </code></pre>
  
  <p>I am trying to plot a graph with Month vs ArrDelay. From the above code I am getting Month as number. So I tried with the below option </p>
  
  <pre><code>udf = UserDefinedFunction(lambda x: calendar.month_abbr[int(x)], StringType())
  new_df_mappedCarrierNames = df_mappedCarrierNames.select(*[udf(column).alias(name) if column == name else column for column in df_mappedCarrierNames.columns])
  </code></pre>
  
  <p>it works but, in my graph it's not in sorted order. whereas if I use the month numbers, it is in sorted order. My issue is in finding out how to map month numbers to month names in sorted order from Jan to dec.
  Thanks in advance for the replies.</p>