Skip to content

Commit

Permalink
Avoid unneeded reset_index in DataFrameGroupBy.describe.
Browse files Browse the repository at this point in the history
  • Loading branch information
ueshin committed Dec 3, 2020
1 parent 138c7b8 commit 1e6f3ea
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions databricks/koalas/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2593,7 +2593,7 @@ def describe(self) -> DataFrame:
"DataFrameGroupBy.describe() doesn't support for string type for now"
)

kdf = self.aggregate(["count", "mean", "std", "min", "quartiles", "max"]).reset_index()
kdf = self.aggregate(["count", "mean", "std", "min", "quartiles", "max"])
sdf = kdf._internal.spark_frame
agg_column_labels = [col._column_label for col in self._agg_columns]
formatted_percentiles = ["25%", "50%", "75%"]
Expand All @@ -2614,12 +2614,8 @@ def describe(self) -> DataFrame:
data_columns = map(name_like_string, column_labels)

# Reindex the DataFrame to reflect initial grouping and agg columns.
internal = InternalFrame(
internal = kdf._internal.copy(
spark_frame=sdf,
index_spark_columns=[
scol_for(sdf, kser._internal.data_spark_column_names[0]) for kser in self._groupkeys
],
index_names=[kser._column_label for kser in self._groupkeys],
column_labels=column_labels,
data_spark_columns=[scol_for(sdf, col) for col in data_columns],
)
Expand Down

0 comments on commit 1e6f3ea

Please sign in to comment.