E is the right option.
See code below with Spark 3.5.1
# Summary statistics of a DataFrame
from pyspark.sql import SparkSession
from pyspark.sql.functions import col
from pyspark.errors import PySparkTypeError
spark = SparkSession.builder.appName("MyApp").getOrCreate()
data = [
(0, 43161),
(1, 51200),
(2, None),
(3, 78367),
(4, None),
]
storesDF = spark.createDataFrame(data, ["storeID", "sqft"])
try:
storesDF.summary("mean").show()
except Exception as e:
print(e)
try:
storesDF.describe(all = True).show()
except Exception as e:
print(e)
try:
storesDF.describe("all").show()
except Exception as e:
print(e)
try:
storesDF.summary("all").show()
except Exception as e:
print(e)
try:
storesDF.describe().show()
except Exception as e:
print(e)
The answer is B.
Explanation: The describe() method in DataFrame returns a DataFrame with summary statistics for all numeric columns in the input DataFrame. By default, only the count, mean, standard deviation, minimum, and maximum values are returned, but additional statistics can be specified with the percentiles parameter. Setting the all parameter to True will include non-numeric columns in the output as well. Therefore, option B is the correct answer.
Option A is not correct, as the summary() method only returns summary statistics for the specified column(s) and is not a valid option for returning summary statistics for all columns in the DataFrame.
Option C is not correct, as the describe() method does not have an "all" option.
Option D is also not correct, as the summary() method only returns summary statistics for the specified column(s) and does not have an "all" option.
Option E is not incorrect, but it does not specify whether to include non-numeric columns in the output. Therefore, option B is a better answer.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
jds0
4 months agodbdantas
7 months, 2 weeks agoazure_bimonster
9 months, 3 weeks agomahmoud_salah30
11 months agosouha_axa
1 year, 3 months agocookiemonster42
1 year, 3 months agozozoshanky
1 year, 3 months agozozoshanky
1 year, 4 months agocookiemonster42
1 year, 3 months ago4be8126
1 year, 7 months agoZSun
1 year, 5 months ago8605246
1 year, 4 months agoDeuterium
1 year, 4 months agocookiemonster42
1 year, 3 months agojuadaves
1 year, 1 month ago