You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The output from .groups on a grouped DataFrame should be handled similarly to a large DataFrame, where beyond a certain length, the data is displayed in a summary form rather than output in its entirety.
This truncation should occur both at the group level (large number of groups) and per-group (large amount of data points in a group).
The text was updated successfully, but these errors were encountered:
bump. What about the groups property being a DataFrame with nans filing unequal group sizes? I don't know about others, but I frequently find myself converting groups to a DataFrame.
Truncation on the per-group basis already works now, because indices in pandas have their own __repr__.
pd.DataFrame({'a': [random.randint(0, 100) for j in range(10000)]}).groupby('a').groups
As for the group-level truncation, that's a bit tricky, because the .groups property is a plain dictionary. What could be done is that we could create a class that inherits from dict and adds a custom __repr__ and nothing else. Something along these lines:
class DataFrameGroups(dict):
def __repr__(self):
if len(self) < 30:
return super().__repr__()
for k, v in self.items():
pass # build representation here
The output from .groups on a grouped DataFrame should be handled similarly to a large DataFrame, where beyond a certain length, the data is displayed in a summary form rather than output in its entirety.
This truncation should occur both at the group level (large number of groups) and per-group (large amount of data points in a group).
The text was updated successfully, but these errors were encountered: