Skip to content

DataFrameGroupBy.aggregate engine='numba' doesn't pass index #43133

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

Closed
2 of 3 tasks
richbwood opened this issue Aug 20, 2021 · 1 comment · Fixed by #43172
Closed
2 of 3 tasks

DataFrameGroupBy.aggregate engine='numba' doesn't pass index #43133

richbwood opened this issue Aug 20, 2021 · 1 comment · Fixed by #43172
Labels
Apply Apply, Aggregate, Transform, Map Bug Groupby numba numba-accelerated operations
Milestone

Comments

@richbwood
Copy link

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

df = pd.DataFrame({'group': ['A', 'A', 'B'], 'v': [4, 5, 6]}, index=[-1, -2, -3])

def f(values, index):
    return np.mean(index)
df.groupby('group').aggregate(f, engine='numba')

# Result is:
#          v
# group     
# A      0.5
# B      2.0

Problem description

The behaviour when engine='numba' is inconsistent with engine='cython':

def f_cython(x):
    return np.mean(x.index)
df.groupby('group').aggregate(f_cython, engine='cython')

# Result is:
#          v
# group     
# A      -1.5
# B      -3.0

Furthermore engine='numba' would be more useful if it calls func with the DataFrame index.

Expected Output

         v
group     
A      -1.5
B      -3.0

Output of pd.show_versions()

INSTALLED VERSIONS

commit : c7f7443
python : 3.7.3.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-80-generic
Version : #90-Ubuntu SMP Fri Jul 9 22:49:44 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 1.3.1
numpy : 1.20.3
pytz : 2021.1
dateutil : 2.8.2
pip : 19.2.3
setuptools : 52.0.0.post20210125
Cython : 0.29.24
pytest : 6.2.4
hypothesis : 6.14.1
sphinx : 4.0.2
blosc : None
feather : None
xlsxwriter : 3.0.1
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.1
IPython : 7.26.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 2021.07.0
fastparquet : None
gcsfs : None
matplotlib : 3.1.1
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.22
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.53.1

@richbwood richbwood added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 20, 2021
@Navaneethan2503
Copy link

I would like to work on this issue , can you make assign to me @richbwood

@mroeschke mroeschke added Apply Apply, Aggregate, Transform, Map Groupby numba numba-accelerated operations and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Aug 22, 2021
@simonjayhawkins simonjayhawkins added this to the 1.4 milestone Aug 26, 2021
@mroeschke mroeschke modified the milestones: 1.4, 1.3.3 Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Apply Apply, Aggregate, Transform, Map Bug Groupby numba numba-accelerated operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants