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.
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