Evaluate PySpark DataFrame Statistics with df.show()
Short answer
B You must use df.describe() or df.summary() to calculate statistics, as df.show() only displays DataFrame rows.
Question
Key Takeaways
The question tests PySpark DataFrame evaluation methods, and the common trap is confusing a data display function (show) with a statistical computation function (describe).
This page clarifies why the PySpark expression df.show() fails to calculate statistical summaries like min, max, mean, and standard deviation for a Spark DataFrame. It establishes that df.describe() or df.summary() are the correct methods for this goal.
Common mistake: Choosing Yes because df.show() successfully interacts with the DataFrame, failing to realize it only displays rows rather than computing statistical metrics.
Expert Analysis
Why the Answer Is Correct
The correct answer is B (No) becausedf.show simply prints the top rows of the DataFrame to the console in a tabular format. It does not perform any statistical computations such as calculating min, max, mean, or standard deviation. Therefore, using df.show completely fails to meet the stated goal of evaluating the data for these specific statistics.Why the Other Options Are Wrong
Option A (Yes) is incorrect because it assumesdf.show calculates statistical metrics. While show is frequently used to preview data during development, it lacks any underlying logic to aggregate and compute descriptive statistics across string and numeric columns.Community Comment Notes
Multiple commenters pointed out thatdf.show only displays data, as stilferx noted with "df.show - shows the data in the dataframe". The correct method to compute these statistics is df.describe, which SamuComqi and others highlighted by stating "The correct syntax is df.describe". Official Reference
- https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.DataFrame.show.html
- https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.DataFrame.describe.html
These links open the official vendor documentation in a new tab.
Exam Strategy
Know the exact purpose of common PySpark DataFrame methods. If a question asks for statistics (min, max, mean, stddev), immediately look for describe() or summary(), not display methods like show() or print().
Community Votes
100% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 6 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors, not of islever. The comments shown first are the most substantive of the thread — ranked by depth, community endorsement and relevance; expand the list below to read the rest.
From public community threads 6
-
282b85d 👍 3 Answered BCorrect methods: Use df.describe().show() for basic statistics and df.agg() with appropriate functions (min, max, mean, stddev) for detailed statistics.
-
SamuComqi 👍 2 Answered BThe correct syntax is df.describe(). Sources: describe --> https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.DataFrame.describe.html show --> https://spark.apache.org/docs/latest/api/python/reference/pyspark.sql/api/pyspark.sql.DataFrame.show.html
-
stilferx 👍 2 Answered BIMHO, NOOOOO df.show() - shows the data in the dataframe
-
XiltroX 👍 1 Answered Bdf.summary() is the only right answer.
-
a_51 👍 2 Answered BUse describe
Show 1 more comment
-
Momoanwar 👍 1 Answered BNo show is to display data
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.
Related Analysis
Practice All DP-600 Questions
Access 115 questions with complete answers and detailed explanations.
View Full DP-600 Practice Test →