在Pyspark中基于列中的多个值合并行

在Pyspark中基于列中的多个值合并行,pyspark,apache-spark-sql,Pyspark,Apache Spark Sql,我有两个栏目,分别是饮料和香烟,其中包含多个值。我基本上想通过合并以下行来计算饮酒和吸烟的人数: 喝酒=经常、拼命、很少、社交、非常频繁 吸烟=有时,试图戒烟,喝酒时,是的 +-----------+-----+ | drinks|count| +-----------+-----+ | often| 2296| |desperately| 123| | not at all| 1932| | rarely| 3275| | socially|19403| | v

我有两个栏目,分别是饮料和香烟,其中包含多个值。我基本上想通过合并以下行来计算饮酒和吸烟的人数: 喝酒=经常、拼命、很少、社交、非常频繁 吸烟=有时,试图戒烟,喝酒时,是的

+-----------+-----+
|     drinks|count|
+-----------+-----+
|      often| 2296|
|desperately|  123|
| not at all| 1932|
|     rarely| 3275|
|   socially|19403|
| very often|  228|
+-----------+-----+

+--------------+-----+
|        smokes|count|
+--------------+-----+
|     sometimes| 1798|
|trying to quit|  753|
|            no|22172|
| when drinking| 1474|
|           yes| 1060|
+--------------+-----+