Not sure that is feasible, but I'm trying to achieve the following with df.groupby()
: let's say we have the following dataframe
name target
A 1
A 2
A 0.5
B 3
B 1
B 2
C 0.6
C 1.2
and I want to group it based on name
without losing the original information on target
. My expected output would be something like:
name target count
A 1 3
2
0.5
B 3 3
1
2
C 0.6 2
1.2