a = pd.DataFrame({"a":[1,1,1,1,1,2,2,2,2,2], "b":range(10)})
a.groupby('a').apply(lambda df: print("***\n" + str(df) + "\n***\n"))
I am expecting the lambda function be called exactly once for every group, but it has been call twice for the first group. Any one know why this happen?
***
a b
0 1 0
1 1 1
2 1 2
3 1 3
4 1 4
***
***
a b
0 1 0
1 1 1
2 1 2
3 1 3
4 1 4
***
***
a b
5 2 5
6 2 6
7 2 7
8 2 8
9 2 9
***