elastic / elastic/eland

Groupby object does not allow subscripting unlike pandas

Open
#549 0 comments 1 reaction 0 assignees View on GitHub
enhancement topic:dataframe
Dominant language
Python
Stars
693
Forks
112
PR merge metrics
No merged PRs in 30d

Description

**Description**
Encountered an error when trying to access a column in an eland DataFrame using the `groupby()` method.

`grouped_data = df.groupby('feature')['used']`

**Expected object**
`pandas.core.frame.DataFrame`

**Actual behaviour**
Throws TypeError
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_20028\2953508713.py in
1 #feature_max = df.groupby('feature')['used'].agg(['min', 'max'])
2 #print(feature_max)
----> 3 grouped_data = df.groupby('feature')['used'].agg(max_value='max')

TypeError: 'DataFrameGroupBy' object is not subscriptable`

Contributor guide

Open the contributing guide

Research direction

Start at the groupby() entry point and the DataFrameGroupBy object shown in the traceback, then reproduce df.groupby('feature')['used'].agg(max_value='max'). Done means column subscripting works like the reported pandas usage and the aggregation no longer raises TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, pandas, python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.