Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid unneeded reset_index in DataFrameGroupBy.describe. #1951

Merged
merged 1 commit into from
Dec 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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