How to convert list of dictionaries into Pyspark DataFrame ? Last Updated : 30 May, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we are going to discuss the creation of the Pyspark dataframe from the list of dictionaries. We are going to create a dataframe in PySpark using a list of dictionaries with the help createDataFrame() method. The data attribute takes the list of dictionaries and columns attribute takes the list of names. dataframe = spark.createDataFrame(data, columns) Example 1: Python3 # importing module import pyspark # importing sparksession from # pyspark.sql module from pyspark.sql import SparkSession # creating sparksession and giving # an app name spark = SparkSession.builder.appName('sparkdf').getOrCreate() # list of dictionaries of students data data = [{"Student ID": 1, "Student name": "sravan"}, {"Student ID": 2, "Student name": "Jyothika"}, {"Student ID": 3, "Student name": "deepika"}, {"Student ID": 4, "Student name": "harsha"}] # creating a dataframe dataframe = spark.createDataFrame(data) # display dataframe dataframe.show() Output: Example 2: Python3 # importing module import pyspark # importing sparksession from # pyspark.sql module from pyspark.sql import SparkSession # creating sparksession and giving # an app name spark = SparkSession.builder.appName('sparkdf').getOrCreate() # list of dictionaries of crop data data = [{"Crop ID": 1, "name": "rose", "State": "AP"}, {"Crop ID": 2, "name": "lilly", "State": "TS"}, {"Crop ID": 3, "name": "lotus", "State": "Maharashtra"}, {"Crop ID": 4, "name": "jasmine", "State": "AP"}] # creating a dataframe dataframe = spark.createDataFrame(data) # display dataframe dataframe.show() Output: Example 3: Python3 # importing module import pyspark # importing sparksession from # pyspark.sql module from pyspark.sql import SparkSession # creating sparksession and giving # an app name spark = SparkSession.builder.appName('sparkdf').getOrCreate() # list of dictionaries of crop data data = [{"Crop ID": 1, "name": "rose", "State": "AP"}, {"Crop ID": 2, "name": "lilly", "State": "TS"}, {"Crop ID": 3, "name": "lotus", "State": "Maharashtra"}, {"Crop ID": 4, "name": "jasmine", "State": "AP"}] # creating a dataframe dataframe = spark.createDataFrame(data) # display dataframe count dataframe.count() Output: 4 Comment More infoAdvertise with us Next Article How to convert list of dictionaries into Pyspark DataFrame ? S sravankumar_171fa07058 Follow Improve Article Tags : Python Python-Pyspark Practice Tags : python Similar Reads Convert Python Dictionary List to PySpark DataFrame In this article, we will discuss how to convert Python Dictionary List to Pyspark DataFrame. It can be done in these ways: Using Infer schema.Using Explicit schemaUsing SQL Expression Method 1: Infer schema from the dictionary We will pass the dictionary directly to the createDataFrame() method. Syn 3 min read Convert PySpark DataFrame to Dictionary in Python In this article, we are going to see how to convert the PySpark data frame to the dictionary, where keys are column names and values are column values. Before starting, we will create a sample Dataframe: Python3 # Importing necessary libraries from pyspark.sql import SparkSession # Create a spark se 3 min read Python | Convert list of nested dictionary into Pandas dataframe Given a list of the nested dictionary, write a Python program to create a Pandas dataframe using it. We can convert list of nested dictionary into Pandas DataFrame. Let's understand the stepwise procedure to create a Pandas Dataframe using the list of nested dictionary. Convert Nested List of Dictio 4 min read How to convert Dictionary to Pandas Dataframe? Converting a dictionary into a Pandas DataFrame is simple and effective. You can easily convert a dictionary with key-value pairs into a tabular format for easy data analysis. Lets see how we can do it using various methods in Pandas.1. Using the Pandas ConstructorWe can convert a dictionary into Da 2 min read Convert PySpark dataframe to list of tuples In this article, we are going to convert the Pyspark dataframe into a list of tuples. The rows in the dataframe are stored in the list separated by a comma operator. So we are going to create a dataframe by using a nested list Creating Dataframe for demonstration: Python3 # importing module import p 2 min read Like