Have you made any progress on this? If not, it's possible the question is not clear enough and other users could use more info. Perhaps screenshots will allow us to better understand the issue.
You can do a CountD in Python for sure. Depending on the library you are using (for example Pandas), it can be as simple as a line of code.
It's hard to help you more withou information about the Python code you are using.