Python pandas: Add a column to my dataframe that counts a variable <p>I have a dataframe 'gt' like this:</p> <pre><code>org group org1 1 org2 1 org3 2 org4 3 org5 3 org6 3 </code></pre> <p>and I would like to add column 'count' to gt dataframe to counts number member of the groups, expected results like this:</p> <pre><code>org group count org1 1 2 org2 1 2 org3 2 1 org4 3 3 org5 3 3 org6 3 3 </code></pre> <p>I know how to do it per one item of the group, but do not know how to make the count repeated for all of the group items, here is the code I have used: </p> <pre><code>gtcounts = gt.groupby('group').count() </code></pre> <p>Can anybody help?</p>