Skip to content

Commit c281373

Browse files
authored
Temporary groupkeys should preserve the names. (#1600)
Temporary group keys should preserve the names. ```py >>> kdf = ks.DataFrame({"a": [1, 2, 6, 4, 4, 6, 4, 3, 7], "b": [4, 2, 7, 3, 3, 1, 1, 1, 2], "c": [4, 2, 7, 3, None, 1, 1, 1, 2], "d": list("abcdefght")}, index=[0, 1, 3, 5, 6, 8, 9, 9, 9]) >>> kdf.groupby(kdf.b + 1).sum().sort_index() a b c __tmp_groupkey_0__ 2 13 3 3.0 3 9 4 4.0 4 8 6 3.0 5 1 4 4.0 8 6 7 7.0 ``` This should be: ```py >>> pdf.groupby(pdf.b + 1).sum().sort_index() a b c b 2 13 3 3.0 3 9 4 4.0 4 8 6 3.0 5 1 4 4.0 8 6 7 7.0 ```
1 parent 5a11db6 commit c281373

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

databricks/koalas/groupby.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,13 +2198,13 @@ def assign_columns(kdf, this_column_labels, that_column_labels):
21982198
@staticmethod
21992199
def _resolve_grouping(kdf: DataFrame, by: List[Union[Series, Tuple[str, ...]]]) -> List[Series]:
22002200
new_by_series = []
2201-
for i, col_or_s in enumerate(by):
2201+
for col_or_s in by:
22022202
if isinstance(col_or_s, Series):
22032203
if col_or_s._kdf is kdf:
22042204
new_by_series.append(col_or_s)
22052205
else:
22062206
# Rename to distinguish the key from a different DataFrame.
2207-
new_by_series.append(col_or_s.rename("__tmp_groupkey_{}__".format(i)))
2207+
new_by_series.append(col_or_s.rename(col_or_s.name))
22082208
elif isinstance(col_or_s, tuple):
22092209
kser = kdf[col_or_s]
22102210
if not isinstance(kser, Series):

0 commit comments

Comments
 (0)