|
|
完美的杯子 · 山西省介休市加快教育均衡发展采访纪行- ...· 2 月前 · |
|
|
俊逸的企鹅 · 創造一個心理病態:七種最危險的暗黑心靈- ...· 3 月前 · |
|
|
豪情万千的洋葱 · 2024上海电竞大师赛开幕· 3 月前 · |
|
|
打酱油的椰子 · 白娘子图片-白娘子图片素材免费下载-千库网· 4 月前 · |
|
|
严肃的筷子 · 与不断增大的数据流量密切相关的光纤熔接机全球 ...· 4 月前 · |
Prints the first
n
rows of the DataFrame to the console.
New in version 1.3.0.
Changed in version 3.4.0: Supports Spark Connect.
Number of rows to show.
If set to
True
, truncate strings longer than 20 chars.
If set to a number greater than one, truncates long strings to length
truncate
and align cells right.
If set to
True
, print output rows vertically (one line per column value).
Examples
>>> df = spark.createDataFrame([
... (14, "Tom"), (23, "Alice"), (16, "Bob"), (19, "This is a super long name")],
... ["age", "name"])
Show DataFrame
>>> df.show()
+---+--------------------+
|age| name|
+---+--------------------+
| 14| Tom|
| 23| Alice|
| 16| Bob|
| 19|This is a super l...|
+---+--------------------+
Show only top 2 rows.
>>> df.show(2)
+---+-----+
|age| name|
+---+-----+
| 14| Tom|
| 23|Alice|
+---+-----+
only showing top 2 rows
Show full column content without truncation.
>>> df.show(truncate=False)
+---+-------------------------+
|age|name |
+---+-------------------------+
|14 |Tom |
|23 |Alice |
|16 |Bob |
|19 |This is a super long name|
+---+-------------------------+
Show DataFrame where the maximum number of characters is 3.
>>> df.show(truncate=3)
+---+----+
|age|name|
+---+----+
| 14| Tom|
| 23| Ali|
| 16| Bob|
| 19| Thi|
+---+----+
Show DataFrame vertically.
>>> df.show(vertical=True)
-RECORD 0--------------------
age | 14
name | Tom
-RECORD 1--------------------
age | 23
name | Alice
-RECORD 2--------------------
age | 16
name | Bob
-RECORD 3--------------------
age | 19
name | This is a super l...