I have a dataframe like this, where the codes column is currently strings.
| Station | Codes |
|---|---|
| 1 | 1,2 |
| 1 | 1 |
| 2 | 1 |
| 2 | 2,5 |
| 2 | 2,3 |
| 3 | 1 |
I want to see the count of each code ordered by station. I have tried to use the explode function but the default behavior is to overwrite all strings with only one number as NaN.
| Station | Codes | Count |
|---|---|---|
| 1 | 1 | 2 |
| 1 | 2 | 1 |
| 2 | 1 | 1 |
| 2 | 2 | 2 |
| 2 | 3 | 1 |
| 2 | 5 | 1 |
| 3 | 1 | 1 |