HyukjinKwon commented on a change in pull request #34931:
URL: https://github.com/apache/spark/pull/34931#discussion_r774312300
##########
File path: python/pyspark/pandas/frame.py
##########
@@ -8828,22 +8847,147 @@ def describe(self, percentiles: Optional[List[float]]
= None) -> "DataFrame":
else:
percentiles = [0.25, 0.5, 0.75]
- formatted_perc = ["{:.0%}".format(p) for p in sorted(percentiles)]
- stats = ["count", "mean", "stddev", "min", *formatted_perc, "max"]
+ # Identify the cases
+ is_all_string_type = (
+ len(psser_numeric) == 0 and len(psser_timestamp) == 0 and
len(psser_string) > 0
+ )
+ is_all_numeric_type = len(psser_numeric) > 0 and len(psser_timestamp)
== 0
+ has_timestamp_type = len(psser_timestamp) > 0
+ has_numeric_type = len(psser_numeric) > 0
+ has_null_columns = len(null_columns) > 0
+
+ if is_all_string_type:
+ # Handling string type columns
+ # We will retrive the `count`, `unique`, `top` and `freq`.
+ internal = self._internal.resolved_copy
+ exprs_string = [
+ internal.spark_column_for(psser._column_label) for psser in
psser_string
+ ]
+ sdf = internal.spark_frame.select(*exprs_string)
+
+ # Get `count` & `unique` for each columns
+ counts, uniques = map(lambda x: x[1:], sdf.summary("count",
"count_distinct").take(2))
+
+ # Get `top` & `freq` for each columns
+ tops = []
+ freqs = []
+ # TODO(SPARK-37711): We should do it in single pass since invoking
Spark job
+ # for every columns is too expensive.
Review comment:
```suggestion
# for every columns is too expensive.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]