I have a dataframe in which I want to extract only those rows which have common dates (skipping time part of datetime) among different Party .
Example Dataframe :
| Party | Date & Time |
|---|---|
| A | 2021-10-01 8:30:40 |
| A | 2021-10-01 9:45:40 |
| A | 2021-10-01 10:50:40 |
| A | 2021-10-02 7:30:40 |
| A | 2021-10-02 7:30:40 |
| B | 2021-10-01 8:30:40 |
| B | 2021-10-01 8:30:40 |
| B | 2021-10-05 8:25:40 |
| C | 2021-10-01 6:10:40 |
| C | 2021-10-05 10:25:30 |
Output I want : In Input Dataframe A,B and C party have common date 2021-10-01 and B,C party have common date 2021-10-05 .I want all these rows irrespective of different times.
| Party | Date & Time |
|---|---|
| A | 2021-10-01 8:30:40 |
| A | 2021-10-01 9:45:40 |
| A | 2021-10-01 10:50:40 |
| B | 2021-10-01 8:30:40 |
| B | 2021-10-01 8:30:40 |
| B | 2021-10-05 8:25:30 |
| C | 2021-10-01 6:10:40 |
| C | 2021-10-05 10:25:30 |
The code I tried :
df.loc[df['Date & Time'].dt.date.duplicated(keep=False)]
but it includes dates that are only found in same Party too. I want all the rows that have common dates among different Parties.