itholic commented on a change in pull request #34931:
URL: https://github.com/apache/spark/pull/34931#discussion_r773657795
##########
File path: python/pyspark/pandas/frame.py
##########
@@ -8828,22 +8847,138 @@ 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
+ only_string_cols = (
+ len(psser_numeric) == 0 and len(psser_timestamp) == 0 and
len(psser_string) > 0
+ )
+ only_numeric_cols = len(psser_numeric) > 0 and len(psser_timestamp) == 0
+ all_timestamp_cols = len(psser_numeric) == 0 and len(psser_timestamp)
> 0
+ any_timestamp_cols = len(psser_numeric) > 0 and len(psser_timestamp) > 0
+
+ if only_string_cols:
+ # Handling string type columns
+ # We will retrive the `count`, `unique`, `top` and `freq`.
+ exprs_string = [psser.spark.column for psser in psser_string]
+ sdf = self._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: We should do it in single pass since invoking Spark job
for every columns
Review comment:
Added, thanks!
--
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]