pyspark.sql.DataFrame.show

DataFrame.show(n=20, truncate=True, vertical=False)[source]

Prints the first n rows to the console.

New in version 1.3.0.

Parameters
nint, optional

Number of rows to show.

truncatebool, optional

If set to True, truncate strings longer than 20 chars by default. If set to a number greater than one, truncates long strings to length truncate and align cells right.

verticalbool, optional

If set to True, print output rows vertically (one line per column value).

Examples

>>> df
DataFrame[age: int, name: string]
>>> df.show()
+---+-----+
|age| name|
+---+-----+
|  2|Alice|
|  5|  Bob|
+---+-----+
>>> df.show(truncate=3)
+---+----+
|age|name|
+---+----+
|  2| Ali|
|  5| Bob|
+---+----+
>>> df.show(vertical=True)
-RECORD 0-----
 age  | 2
 name | Alice
-RECORD 1-----
 age  | 5
 name | Bob