0

I have a pandas DataFrame in python with one column A with numerical values:

A    
11
12
13
12
14

I want to add a column that contains a counter that counts the number of elements per group up to that index in column A, like this:

A    B
11   1
12   1
13   1
12   2
14   1

How do I create column B?

Svalbard
  • 182
  • 2
  • 13

0 Answers0