Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 821 Bytes

511. Game Play Analysis I.md

File metadata and controls

31 lines (26 loc) · 821 Bytes

511. Game Play Analysis I

Question Link

Intuition

Knowledge of this test:

  • if you don't use inplace = True in rename, the output will not change the name of the column.

So you have 2 choices:

  • No.1:
result = activity.rename(columns={'event_date':'first_login'})
return result
  • N0.2:
activity.rename(columns={'event_date':'first_login'},inplace=True)
return activity

The solution below is the latter one.

Code

import pandas as pd

def game_analysis(activity: pd.DataFrame) -> pd.DataFrame:

    activity=activity.loc[:,['player_id','event_date']]
    activity=activity.groupby(['player_id'])['event_date'].min().reset_index()
    activity.rename(columns={'event_date':'first_login'},inplace=True)
    
    return activity