title: How to get name of dataframe column in PySpark?
body: <p>In pandas, this can be done by <code>column.name</code>.</p>
  <p>But how to do the same when it's a column of Spark dataframe?</p>
  <p>E.g. the calling program has a Spark dataframe: <code>spark_df</code></p>
  <pre><code>&gt;&gt;&gt; spark_df.columns
  ['admit', 'gre', 'gpa', 'rank']
  </code></pre>
  <p>This program calls my function: <code>my_function(spark_df['rank'])</code><br />
  In <code>my_function</code>, I need the name of the column, i.e. <code>'rank'</code>.</p>
  <p>If it was pandas dataframe, we could use this:</p>
  <pre><code>&gt;&gt;&gt; pandas_df['rank'].name
  'rank'
  </code></pre>