0

I have a pandas dataframe with many different elements, and I want to group similar ones and add another column representing the frequency of them. For example:

+-------+------+
| Atr1  | Atr2 |
+-------+------+
| 1     |  A   |
+-------+------+
| 2     |  B   |
+-------+------+
| 1     |  A   |
+-------+------+
| 3     |  C   |
+-------+------+

I want to get:

+-------+-------+-------+
| Atr1  | Atr2  | COUNT |
+-------+-------+-------+
| 1     |  A    |  2    |
+-------+-------+-------+
| 2     |  B    |  1    |
+-------+-------+-------+
| 3     |  C    |  1    |
+-------+-------+-------+

How can I do it?

jartymcfly
  • 1,753
  • 6
  • 27
  • 47

0 Answers0