-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Description
This bug is easy to reproduce:
def printA(group):
print group.A.values[0]
return 0
pandas.DataFrame({'A': [0,0,1,1], 'B': [0,1,0,1]}).groupby('A').apply(printA)
This should print
0
1
and return a Series containing two zeroes. Although it does return the expected Series, it prints
0
0
1
So, the function printA is being applied to the first group twice. This doesn't seem to affect the eventual returned result of apply, but it duplicates any side effects, and if printA performed some expensive computation, it would increased the time to completion.
PENGZhaoqing, leornil42, summerela, nocibambi, levitation and 2 more