Viewing the content of a Spark Dataframe Column
You can access underlying RDD
and map over it
df.rdd.map(lambda r: r.zip_code).collect()
You can also use select
if you don't mind results wrapped using Row
objects:
df.select('zip_code').collect()
Finally, if you simply want to inspect content then show
method should be enough:
df.select('zip_code').show()
You can simply write:
df.select('your column's name').show()
In your case here, it will be:
df.select('zip_code').show()
To view the complete content:
df.select("raw").take(1).foreach(println)
(show
will show you an overview).