I'm getting row counts for a particular column like so:
subreddit_count = df['body'].groupby(df['subreddit']).agg(['count'])
Which returns the following df:
subreddit count
0 0xProject 12
1 100sexiest 1
2 100yearsago 2
3 1022 3
4 1200isjerky 2
5 1200isplenty 37
6 1200isplentyketo 1
7 12ozmouse 1
8 12thMan 4
9 12winArenaLog 1
10 13ReasonsWhy 5
11 13or30 3
12 14ers 1
13 1500isplenty 1
14 15SecondStories 3
15 18650masterrace 1
16 18_19 10
17 1911 5
18 195 2
19 19KidsandCounting 4
20 1P_LSD 18
21 2007oneclan 2
22 2007scape 1044
23 2010sMusic 1
24 21savage 1
25 22lr 1
26 23andme 9
27 240sx 4
28 24CarrotCraft 1
29 24hoursupport 5
I would like to essentially undo the groupby so that these counts are added to every row in the original df. I've tried using reset_index to no avail. What's the right approach here?