Last active
October 11, 2022 04:49
-
-
Save kovid-r/883f23ba35a179fe921869e71d924c3e to your computer and use it in GitHub Desktop.
Creating DataFrames using Row construct
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyspark.sql import Row | |
# populate two rows with random values | |
f1 = Row(original_title='Eroica', budget='13393950', year=1992) | |
f2 = Row(original_title='Night World', budget='1255930', year=1998) | |
# store the two rows in an array and pass it to Spark | |
films = [f1, f2] | |
df = spark.createDataFrame(films) | |
df.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment