2016-01-04 38 views

回答

2

您可以随时使用pprint这样的:

import pprint 
pprint(fields) 

,但如果你想打印模式,最好是使用DataFrame.printSchema

+0

谢谢,这是一个不错的解决方法。我实际上是按照这个教程(http://www.nodalpoint.com/spark-data-frames-from-csv-files-handling-headers-column-types/),作者可以逐行打印pprint。我想知道他/她是如何做到的。 –

+2

作者可能使用[IPython](http://ipython.org/) – karlson

1

我通常使用:

fields.foreach(println) 

它也可以当您从RDD或数据框检索数据:

myDf.collect().foreach(println)