1

I have the following table:

Timestamp  ID  RandomColumn
01-01-2019 1 True
01-01-2019 2 True
01-01-2019 3 False
02-01-2019 1 False
02-01-2019 3 True
03-01-2019 2 False

I'd like to calculate the number of appearances of IDs up to a timestamp they appear in Table. Or put differently, for a certain timestamp I want to calculate how often this ID occurred in the past.

The output should, thus, be the following:

Timestamp  ID  RandomColumn  Appearances
01-01-2019 1 True 0
01-01-2019 2 True 0
01-01-2019 3 False 0
02-01-2019 1 False 1
02-01-2019 3 True 1
03-01-2019 1 False 2
03-01-2019 2 False 1

How to this with Pandas?

TheDude
  • 1,205
  • 2
  • 13
  • 21

0 Answers0