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

groupby transform producing different results depending on whether a lambda function was passed or a numpy function was passed #14457

Closed
pirsquared opened this Issue Oct 19, 2016 · 0 comments

Comments

Projects
None yet
2 participants
@pirsquared

stackoverflow
http://stackoverflow.com/q/40141881/2336654

import pandas as pd
import numpy as np

df = pd.DataFrame(dict(A=['a', 'a'], B=[0, 1]))
print(df.groupby('A').transform(np.mean))
# is no the same as
print(df.groupby('A').transform(lambda x: np.mean(x)))

Output of pd.show_versions()

## INSTALLED VERSIONS

commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.19.0
nose: 1.3.7
pip: 8.1.2
setuptools: 27.2.0
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.18.1
statsmodels: 0.6.1
xarray: None
IPython: 5.1.0
sphinx: 1.4.6
patsy: 0.4.1
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: 1.5.3
openpyxl: 2.3.2
xlrd: 1.0.0
xlwt: 1.1.2
xlsxwriter: 0.9.3
lxml: 3.6.4
bs4: 4.5.1
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.13
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.42.0
pandas_datareader: 0.2.1

@jreback jreback added this to the 0.19.1 milestone Oct 21, 2016

jreback added a commit to jreback/pandas that referenced this issue Oct 21, 2016

jreback added a commit to jreback/pandas that referenced this issue Oct 24, 2016

jreback added a commit to jreback/pandas that referenced this issue Oct 25, 2016

@jreback jreback closed this in f99f050 Oct 25, 2016

jorisvandenbossche added a commit to jorisvandenbossche/pandas that referenced this issue Nov 2, 2016

[Backport #14466] BUG: incorrect broadcasting that could casuse dtype…
… coercion in a groupby-transform

closes #14457

Author: Jeff Reback <jeff@reback.net>

Closes #14466 from jreback/transform and squashes the following commits:

ce595b9 [Jeff Reback] BUG: incorrect broadcasting that could casuse dtype coercion in a groupby-transform

(cherry picked from commit f99f050)

amolkahat added a commit to amolkahat/pandas that referenced this issue Nov 26, 2016

BUG: incorrect broadcasting that could casuse dtype coercion in a gro…
…upby-transform

closes #14457

Author: Jeff Reback <jeff@reback.net>

Closes #14466 from jreback/transform and squashes the following commits:

ce595b9 [Jeff Reback] BUG: incorrect broadcasting that could casuse dtype coercion in a groupby-transform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment