How to show full column content in a Spark Dataframe?

前端 未结 14 2134
萌比男神i
萌比男神i 2020-12-07 07:46

I am using spark-csv to load data into a DataFrame. I want to do a simple query and display the content:

val df = sqlContext.read.format(\"com.databricks.spa         


        
相关标签:
14条回答
  • 2020-12-07 08:16

    results.show(20, false) will not truncate. Check the source

    0 讨论(0)
  • 2020-12-07 08:18

    try this command :

    df.show(df.count())
    
    0 讨论(0)
  • 2020-12-07 08:20

    Within Databricks you can visualize the dataframe in a tabular format. With the command:

    display(results)
    

    It will look like

    0 讨论(0)
  • 2020-12-07 08:23

    The other solutions are good. If these are your goals:

    1. No truncation of columns,
    2. No loss of rows,
    3. Fast and
    4. Efficient

    These two lines are useful ...

        df.persist
        df.show(df.count, false) // in Scala or 'False' in Python
    

    By persisting, the 2 executor actions, count and show, are faster & more efficient when using persist or cache to maintain the interim underlying dataframe structure within the executors. See more about persist and cache.

    0 讨论(0)
  • 2020-12-07 08:23

    The following answer applies to a Spark Streaming application.

    By setting the "truncate" option to false, you can tell the output sink to display the full column.

    val query = out.writeStream
              .outputMode(OutputMode.Update())
              .format("console")
              .option("truncate", false)
              .trigger(Trigger.ProcessingTime("5 seconds"))
              .start()
    
    0 讨论(0)
  • 2020-12-07 08:24

    results.show(20,false) did the trick for me in Scala.

    0 讨论(0)
提交回复
热议问题