我想根据 pyspark 中的某些条件创建一个新列。我的数据框 -
id create_date txn_date
1 2019-02-23 23:27:42 2019-08-18 00:00:00
2 2019-08-24 00:10:18 2019-08-24 00:00:00
3 2019-09-16 17:47:56 2018-07-23 00:00:00
4 2019-09-24 01:31:21 2018-05-13 00:00:00
5 2018-12-26 23:28:09 2019-07-15 00:00:00
所有列都是字符串格式。我的条件是——
txn_date >= create_date。基于此条件,我将创建一个新列“is_mem”。
我的最终数据框看起来像 -
id create_date txn_date is_mem
1 2019-02-23 23:27:42 2019-08-18 00:00:00 0
2 2019-08-24 00:10:18 2019-09-24 00:00:00 1
3 2019-09-16 17:47:56 2018-07-23 00:00:00 1
4 2019-09-24 01:31:21 2018-05-13 00:00:00 1
5 2018-12-26 23:28:09 2019-07-15 00:00:00 0
如何在pyspark中做到这一点?