In pandas, this can be done by column.name
.
But how to do the same when it's a column of Spark dataframe?
E.g. the calling program has a Spark dataframe: spark_df
>>> spark_df.columns
['admit', 'gre', 'gpa', 'rank']
This program calls my function: my_function(spark_df['rank'])
In my_function
, I need the name of the column, i.e. 'rank'
.
If it was pandas dataframe, we could use this:
>>> pandas_df['rank'].name
'rank'