-
-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
BugGroupbyNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.good first issue
Milestone
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
df = pd.DataFrame(
data=[
[5, 2, 17, 11, 7, 2, 3],
[5, 2, 17, 41, 7, 2, 3],
[5, 2, 17, 17, 7, 2, 3],
[5, 2, 17, 37, 7, 2, 3],
[5, 2, 17, 7, 7, 2, 3],
[5, 2, 17, 29, 7, 2, 3],
[5, 2, 17, 31, 7, 2, 3],
[5, 2, 17, 2, 7, 2, 3],
[5, 2, 17, 3, 7, 2, 3],
[5, 2, 17, 43, 7, 2, 3],
[5, 2, 17, 5, 7, 2, 3],
[5, 2, 17, 47, 7, 2, 3],
[5, 2, 17, 19, 7, 2, 3],
[5, 2, 17, 23, 7, 2, 3],
],
columns=['A','B','C','D','E','F','G']
)
df.prod()
#A 6103515625
#B 16384
#C 168377826559400929
#D 47299214045268570 <-- correct value
#E 678223072849
#F 16384
#G 4782969
#dtype: int64
df.groupby(['A','B','C','E','F','G']).prod()
# D
#A B C E F G
#5 2 17 7 2 3 47299214045268568 <-- wrong value
Issue Description
During a project that uses pandas groupby prod method I noticed possible bug.
The reproducible example should be clear but the core issue is that is seems that pandas prod() method behaves different
than pandas groupby prod method. The result is inconsistent. In the example, please inspect column "D"
Expected Behavior
Correct output of column D during the groupby operation
Installed Versions
'1.4.1'
Metadata
Metadata
Labels
BugGroupbyNeeds TestsUnit test(s) needed to prevent regressionsUnit test(s) needed to prevent regressionsReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.good first issue