I have a dataframe 'df' that has categorical and POSIXct columns. The data look like:
| Category | DateTime |
|---|---|
| A | 2022-08-29 00:00:00 |
| A | 2022-08-29 00:00:00 |
| A 1 | 2022-08-29 00:00:00 |
| A 1 | 2022-08-29 00:00:00 |
| A 1 | 2022-08-29 00:00:00 |
| B | 2022-08-29 00:00:00 |
| B | 2022-08-29 00:00:00 |
| B | 2022-08-29 00:00:00 |
| B 1 | 2022-08-29 00:00:00 |
| B 1 | 2022-08-29 00:00:00 |
| B 1 | 2022-08-29 00:00:00 |
| B 1 | 2022-08-29 00:00:00 |
| B 1 | 2022-08-29 00:00:00 |
| A | 2022-08-29 02:00:00 |
| A 1 | 2022-08-29 02:00:00 |
| B | 2022-08-29 02:00:00 |
| B | 2022-08-29 02:00:00 |
| B | 2022-08-29 02:00:00 |
| B 1 | 2022-08-29 02:00:00 |
| B 1 | 2022-08-29 02:00:00 |
| B 1 | 2022-08-29 02:00:00 |
I would like to create a new dataframe 'df2' that counts each unique value in column 'Category' that doesn't end with " 1" by column 'DateTime', so that the results look like:
| Category | DateTime | CatCount |
|---|---|---|
| A | 2022-08-29 00:00:00 | 2 |
| B | 2022-08-29 00:00:00 | 3 |
| A | 2022-08-29 02:00:00 | 1 |
| B | 2022-08-29 02:00:00 | 3 |