Пример #1
0
    def create_player_lists(teams, year):
        '''
        create_player_lists: Returns a dataframe with a column DND_IDS, which contains a list of player ids for inactive players.

        Inactive players are defined as players who were listed as DND (did not dress) or NWT (not with team)
        '''
        df_bs = Loader.load_unsorted_boxscore(year)
        # df_inactives = df_inactives[~np.isnan(df_inactives['Date'])]

        # create dataframes with players who DND and NWT
        df_dnd = df_bs[df_bs['COMMENT'].str.contains('DND', na=False)]
        df_without_dnd = df_bs[~df_bs['COMMENT'].str.contains('DND', na=False)]
        df_nwt = df_without_dnd[df_without_dnd['COMMENT'].str.contains(
            'NWT', na=False)]

        # populate list with all player IDs in boxscore
        df_bs.apply((lambda row: teams[row['TEAM_ID']].player_list[row['Date']]
                     .append(row['PLAYER_ID'])),
                    axis=1)

        # populate list with all player IDs who DND
        df_dnd.apply((lambda row: teams[row['TEAM_ID']].inactive_list[row[
            'Date']].append(row['PLAYER_ID'])),
                     axis=1)

        # populate list with all player IDs who were NWT
        df_nwt.apply((lambda row: teams[row['TEAM_ID']].inactive_list[row[
            'Date']].append(row['PLAYER_ID'])),
                     axis=1)
Пример #2
0
    def create_player_lists(teams, year):
        '''
        create_player_lists: Returns a dataframe with a column DND_IDS, which contains a list of player ids for inactive players.

        Inactive players are defined as players who were listed as DND (did not dress) or NWT (not with team)
        '''
        df_bs = Loader.load_unsorted_boxscore(year)
        # df_inactives = df_inactives[~np.isnan(df_inactives['Date'])]

        # create dataframes with players who DND and NWT
        df_dnd = df_bs[df_bs['COMMENT'].str.contains('DND', na=False)]
        df_without_dnd = df_bs[~df_bs['COMMENT'].str.contains('DND', na=False)]
        df_nwt = df_without_dnd[df_without_dnd['COMMENT'].str.contains('NWT', na=False)]

        # populate list with all player IDs in boxscore
        df_bs.apply((lambda row:         teams[row['TEAM_ID']].player_list[row['Date']].append(row['PLAYER_ID'])), axis=1)

        # populate list with all player IDs who DND
        df_dnd.apply((lambda row: teams[row['TEAM_ID']].inactive_list[row['Date']].append(row['PLAYER_ID'])), axis=1)

        # populate list with all player IDs who were NWT
        df_nwt.apply((lambda row: teams[row['TEAM_ID']].inactive_list[row['Date']].append(row['PLAYER_ID'])), axis=1)