Skip to content

Instantly share code, notes, and snippets.

@RaMSFT
Created December 19, 2021 03:41
Show Gist options
  • Select an option

  • Save RaMSFT/c5fa16ee946482030b406644232d099f to your computer and use it in GitHub Desktop.

Select an option

Save RaMSFT/c5fa16ee946482030b406644232d099f to your computer and use it in GitHub Desktop.
# create a python list of tupels list_of_cars
list_of_cars = [(1,'Honda'),(2,'BMW'), (3,'Ford'),(4,'Toyota'),(5,'Skoda'),(6,'Mercedes'),(7,'Tata'),(8,'Audi')]
# create a list with columns of above data
columns = ['id','car_brands']
#Create dataframe using createDataFrame method
list_dataframe = spark.createDataFrame(list_of_cars, columns)
# Show the data from dataframe
list_dataframe.show()
# Display the data from dataframe - in a table format
list_dataframe.display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment