How to show the full contents of a column in the Spark framework?

I use spark-csv to load data into a DataFrame. I want to make a simple request and display the contents:

val df = sqlContext.read.format("com.databricks.spark.csv").option("header", "true").load("my.csv") df.registerTempTable("tasks") results = sqlContext.sql("select col from tasks"); results.show() 

The call seems truncated:

 scala> results.show(); +--------------------+ | col| +--------------------+ |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:15:...| |2015-11-06 07:15:...| |2015-11-16 07:15:...| |2015-11-16 07:21:...| |2015-11-16 07:21:...| |2015-11-16 07:21:...| +--------------------+ 

How to show the full contents of a column?

+140
dataframe spark-csv apache-spark output-formatting
Nov 16 '15 at 7:17
source share
12 answers

results.show(20, false) will not be truncated. Check Source

+267
Nov 16 '15 at 19:24
source share

If you put results.show(false) , the results will not be truncated

+25
Apr 08 '16 at 19:02
source share

Other solutions are good. If these are your goals:

  1. No column truncation
  2. Without losing lines,
  3. Fast and
  4. effective

These two lines are useful ...

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

By saving 2 artist actions β€” counting and displaying β€” are faster and more efficient when using persist or cache to support the temporary data structure in artists. See more about persistence and cache .

+12
Feb 15 '17 at 6:25
source share

Below code will help to view all rows without truncation in each column

 df.show(df.count(), False) 
+10
Feb 05 '17 at 1:21
source share

results.show(20, False) or results.show(20, False) depending on whether you run it in Java / Scala / Python

+9
Mar 08 '17 at 5:40
source share

results.show(false) will show you the entire contents of the column.

Show the default method, limiting to 20, and adding a number before false will show more lines.

+3
Nov 08 '17 at 17:54 on
source share

try this command:

 df.show(df.count()) 
+1
Nov 25 '16 at 20:16
source share

results.show(20,false) helped me in Scala.

+1
Apr 16 '18 at 18:32
source share

Inside the Databricks, you can visualize the data frame in a tabular format. With the command:

 display(results) 

It will look

enter image description here

+1
Sep 10 '18 at 9:12
source share

I use the plugin, the Chrome extension works pretty well:

[ https://userstyles.org/styles/157357/jupyter-notebook-wide.BIZ[1]

0
May 23 '19 at 17:35
source share

I had the same request, and I looked through a lot of materials available on the Internet and found something interesting that removes all doubts. So I was thinking of sharing with you guys as well. Try this code, it works:

 results.show(results.count.toInt) 
-2
Nov 20 '18 at 16:09
source share

Try the following: df.show (some no) will work, but df.show (df.count ()) will not work. df.count gives the output type long, which is not accepted by df.show (), because it accepts an integer type.

-3
Aug 22 '17 at 11:38 on
source share



All Articles