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

Aggregate rows does not work without group key #215

Open
simonaubertbd opened this issue Dec 5, 2024 · 2 comments
Open

Aggregate rows does not work without group key #215

simonaubertbd opened this issue Dec 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@simonaubertbd
Copy link

Hello,

Aggregate rows does not work if we don't specify a group key (i.e. if we want to aggregate on all rows)
image

`Error

No group keys passed!
Show Traceback


ValueError Traceback (most recent call last)
Cell In[24], line 8
3 # Source code generated by Amphi
4 # Date: 2024-12-05 08:55:32
5 # Additional dependencies: pyarrow
6 import pandas as pd
----> 8 aggregate1 = parquetFileInput1.groupby([]).agg(c_phone_min=('c_phone', 'min')).reset_index()
11 __amphi_display_dataframe(aggregate1, dfName="aggregate1", nodeId="node_1733386206267")

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\frame.py:9170, in DataFrame.groupby(self, by, axis, level, as_index, sort, group_keys, observed, dropna)
9167 if level is None and by is None:
9168 raise TypeError("You have to supply one of 'by' and 'level'")
-> 9170 return DataFrameGroupBy(
9171 obj=self,
9172 keys=by,
9173 axis=axis,
9174 level=level,
9175 as_index=as_index,
9176 sort=sort,
9177 group_keys=group_keys,
9178 observed=observed,
9179 dropna=dropna,
9180 )

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby\groupby.py:1329, in GroupBy.init(self, obj, keys, axis, level, grouper, exclusions, selection, as_index, sort, group_keys, observed, dropna)
1326 self.dropna = dropna
1328 if grouper is None:
-> 1329 grouper, exclusions, obj = get_grouper(
1330 obj,
1331 keys,
1332 axis=axis,
1333 level=level,
1334 sort=sort,
1335 observed=False if observed is lib.no_default else observed,
1336 dropna=self.dropna,
1337 )
1339 if observed is lib.no_default:
1340 if any(ping._passed_categorical for ping in grouper.groupings):

File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\pandas\core\groupby\grouper.py:1071, in get_grouper(obj, key, axis, level, sort, observed, validate, dropna)
1068 groupings.append(ping)
1070 if len(groupings) == 0 and len(obj):
-> 1071 raise ValueError("No group keys passed!")
1072 if len(groupings) == 0:
1073 groupings.append(Grouping(Index([], dtype="int"), np.array([], dtype=np.intp)))

ValueError: No group keys passed!`

@tgourdel
Copy link
Contributor

tgourdel commented Dec 5, 2024

Hi Simon, not sure how that works. If you don't select any columns to group by, how should it aggregate your rows?

@tgourdel tgourdel added the bug Something isn't working label Dec 5, 2024
@simonaubertbd
Copy link
Author

@tgourdel like that :

input
image

Transform
image

output
image

Of course, if no group keys, the result is only one row.

Best regards,

Simon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants