I have dataframe called df_engage its columns are ['district_id', 'time', 'pct_access', 'lp_id']
| district_id | time | pct_access | lp_id | 
|---|---|---|---|
| 1000 | 2020-01-01 | 3.60 | 93690 | 
| 1000 | 2020-01-01 | 0.03 | 17941 | 
| 1000 | 2020-01-01 | 0.03 | 65358 | 
| 1000 | 2020-01-01 | 0.57 | 98265 | 
| 1000 | 2020-01-02 | 41.76 | 59257 | 
I have extracted the max pct_access in each day
df_engage_max = df_engage.groupby(['district_id', 'time'], as_index=False)['pct_access'].max()
the result is:
| district_id | time | pct_access | 
|---|---|---|
| 1000 | 2020-01-01 | 3.60 | 
| 1000 | 2020-01-02 | 41.76 | 
| 1000 | 2020-01-03 | 49.76 | 
NOW, I need to append column lp_id from df_engage to df_engage_max based on df_engage_max[['district_id', 'time', 'pct_access']] that means, the result should be:
| district_id | time | pct_access | lp_id | 
|---|---|---|---|
| 1000 | 2020-01-01 | 3.6 | 93690 | 
| 1000 | 2020-01-02 | 41.76 | 59257 | 
any help please :) ?
 
     
     
    