I have a timestamp column and I want to create a year column from this colum. I know how to show it but I am not able to create a column on my dataset. So far I have tried this:
data = data.withColumn('Year', data.select(year(('Date')))
But it throws an error saying:
AssertionError: col should be Column
I am able to show the year doing this:
data.select(year('Date').alias('Year')).show()