Python, Pandas dataframe, merge dataframe’s rows that have same two column values and aggregate data in rows

Solution for Python, Pandas dataframe, merge dataframe’s rows that have same two column values and aggregate data in rows
is Given Below:

I have this DF and I am trying to merge any two rows with similar workDate and ID. I do not know how many columns this DF will have. it might have hundreds of columns so I am looking for a way to merge without having to specify all column names

    |workDate   |ID       | Hours |Groundsman  |names2  |Teachers       |Profs
---------------------------------------------------------------------------------
0   |2020-01-09 |13702    | 1.0   |   Ted      |        |               |
1   |2020-01-09 |13702    | 1.0   |            |Seline  |               |
2   |2020-01-10 |13702    | 20.0  |            |Ted,Sam |               |
3   |2020-01-10 |13702    | 20.0  |            |        |Pete,Norm,Tim  |
4   |2020-01-10 |13702    | 20.0  |            |        |               |Joe

Desired output:

    |workDate   |ID       | Hours |Groundsman  |names2  |Teachers       |Profs
---------------------------------------------------------------------------------
0   |2020-01-09 |13702    | 1.0   |   Ted      |Seline  |               |
1   |2020-01-10 |13702    | 20.0  |            |Ted,Sam |Pete,Norm,Tim  |Joe

I have tried multiple ways of grouping by but non of got me the desired output. As I mentioned DF might have a lot of other columns so I can not use a solution that expects all columns names to be included.
it’s basically group by workDate and ID but I also want to keep all values in other columns

Try:

import pandas as pd
import numpy as np #only required because the example df creation needs np.nan

df = pd.DataFrame({'workDate': {0: '2020-01-09',
  1: '2020-01-09',
  2: '2020-01-10',
  3: '2020-01-10',
  4: '2020-01-10'},
 'ID': {0: 13702, 1: 13702, 2: 13702, 3: 13702, 4: 13702},
 ' Hours': {0: 1.0, 1: 1.0, 2: 20.0, 3: 20.0, 4: 20.0},
 'Groundsman': {0: '   Ted', 1: np.nan, 2: np.nan, 3: np.nan, 4: np.nan},
 'names2': {0: np.nan, 1: 'Seline', 2: 'Ted,Sam', 3: np.nan, 4: np.nan},
 'Teachers': {0: np.nan, 1: np.nan, 2: np.nan, 3: 'Pete,Norm,Tim', 4: np.nan},
 'Profs': {0: np.nan, 1: np.nan, 2: np.nan, 3: np.nan, 4: 'Joe'}})

print(df.groupby(by=['workDate', 'ID']).last().reset_index())

Outputs:

     workDate     ID   Hours Groundsman   names2       Teachers Profs
0  2020-01-09  13702     1.0        Ted   Seline           None  None
1  2020-01-10  13702    20.0       None  Ted,Sam  Pete,Norm,Tim   Joe