问题内容: I have a dataframe loaded by a csv file. This CSV contains data about a recommender system. The struct is: SKU, TYPE_SKU, TYPE_RECOMMENDED, SKU_RECOMMENDED_1, TYPE_SKU_RECOMMENDED_1, SKU_RECOMMENDED_2, TYPE_SKU_RECOMMENDED_2, SKU_RECOMMENDED_3, TYPE_SKU_RECOMMENDED_3, SKU_RECOMMENDED_4, TYPE_SKU_RECOMMENDED_4 So, I have 4 levels of recommended that I need to struct in json/nested struct in the following struct below, using Pyspark. {