enhancementgood first issuehelp wanted
仓库指标
- Star
- (875 star)
- PR 合并指标
- (PR 指标待抓取)
描述
Right now, we only support loading data from numpy arrays. It would be nice if there was a helper function to convert a dataframe of scores to numpy arrays. Some initial code to help what this might look like:
def get_all_return_values(df):
games = list(df['game'].unique())
return_vals = {}
for game in games:
game_df = df[df['game'] == game]
arr = game_df.groupby('wid')['normalized_score'].apply(list).values
return_vals[game] = np.stack(arr, axis=0)
return return_vals
def convert_to_matrix(x):
return np.stack([x[k] for k in sorted(x.keys())], axis=1)
## Usage
# Array of shape (num_runs, num_games, num_steps)`
all_normalized_scores = convert_to_matrix(get_all_return_values(score_df))
The above code assumes we have a pandas Dataframe with keys run_number, 'gameandnormalized_score` containing scores for all steps (in a ordered manner).