【发布时间】:2020-08-21 20:11:54
【问题描述】:
我有一个包含四列的数据框,如下所示,对于每个客户,我有 12 行包含以下详细信息,如示例中所示
Cust_id|slot|trigger_id|coup_type
1| 1| 2101| null
1| 2| 2102| null
1| 3| 2103| null
1| 4| 2104| null
1| 5| 2105| product
1| 6| 2106| null
1| 7| 2107| null
1| 8| 2108| product
1| 9| 2109| null
1| 10| 21010| null
1| 11| 21011| product
1| 12| 21012| product
现在我需要根据 coup_type 执行 slot 移位,这样所有产品 coup 都应该出现在 slot7-10 中,并且分配应该始终从 slot7 开始。移位后的插槽应重新排列如下:-
Cust_id|slot|trigger_id|coup_type
1| 1| 2101| null
1| 2| 2102| null
1| 3| 2103| null
1| 4| 2104| null
1| 5| 2105| null
1| 6| 2106| null
1| 7| 2105| product
1| 8| 2108| product
1| 9| 21011| product
1| 10| 21012| product
1| 11| 21009| null
1| 12| 21010| null
我需要在 pyspark 中执行这个操作。
如果问题不清楚,请告诉我。
提前致谢。
【问题讨论】:
标签: python pyspark analytics data-analysis data-wrangling