The type of the key-value pairs can be customized with the parameters (see below). Here is the complete code to perform the conversion: Run the code, and youll get this dictionary: The above dictionary has the following dict orientation (which is the default): You may pick other orientations based on your needs. Connect and share knowledge within a single location that is structured and easy to search. Solution 1. A-143, 9th Floor, Sovereign Corporate Tower, We use cookies to ensure you have the best browsing experience on our website. Abbreviations are allowed. In the output we can observe that Alice is appearing only once, but this is of course because the key of Alice gets overwritten. A transformation function of a data frame that is used to change the value, convert the datatype of an existing column, and create a new column is known as withColumn () function. Syntax: spark.createDataFrame([Row(**iterator) for iterator in data]). Then we convert the lines to columns by splitting on the comma. Hi Fokko, the print of list_persons renders "