I am using PySpark. I have a column ('dt') in a dataframe ('canon_evt') that this a timestamp. I am trying to remove seconds from a DateTime value. It is originally read in from parquet as a String. I then try to convert it to Timestamp via
canon_evt = canon_evt.withColumn('dt',to_date(canon_evt.dt))
canon_evt= canon_evt.withColumn('dt',canon_evt.dt.astype('Timestamp'))
Then I would like to remove the seconds. I tried 'trunc', 'date_format' or even trying to concatenate pieces together like below. I think it requires some sort of map and lambda combination, but I'm not certain whether Timestamp is an appropriate format, and whether it's possible to get rid of seconds.
canon_evt = canon_evt.withColumn('dyt',year('dt') + '-' + month('dt') +
'-' + dayofmonth('dt') + ' ' + hour('dt') + ':' + minute('dt'))
[Row(dt=datetime.datetime(2015, 9, 16, 0, 0),dyt=None)]