dblackrun / pbpstats

A package to scrape and parse NBA, WNBA and G-League play-by-play data.
MIT License
86 stars 18 forks source link

free throw that shouldn't exist #47

Open shengkelong opened 2 years ago

shengkelong commented 2 years ago

I use this code to count the free throws for each posessions, but every season there is a small number of cases where in this

posession offensive team has 0 points but has free throws. I don't know if it's a code problem or a data problem:

   if isinstance(p, enhanced_pbp.stats_nba.free_throw.StatsFreeThrow):
        current_players = np.sort(p.current_players[team_id_o])
        self.FTA[-1][current_players==p.player1_id]+=1
        if p.is_made:
            self.FTM[-1][current_players==p.player1_id]+=1
dblackrun commented 2 years ago

Do you have an example of where this happens? Game Id and possession/event number?

shengkelong commented 2 years ago

@dblackrun There are many examples(so I think it's my code's problem) for example gameid = 0020000017,0020000019,0020000020,0020000022 in these game most of the possessions the score can fit the number of FG3M3+FG2M2+FTM, except one possession.

This is the difference between the actual points and the points calculated from the shot during the game 0020000017 image

dblackrun commented 2 years ago

Can you be more specific? Without a game id and possession number or event number there is no way I can look into it.

shengkelong commented 2 years ago

@dblackrun I think I find the possession number. a small part of them: <Possession GameId: 0020000017, Period: 2, Number: 25, StartTime: 6:24, EndTime: 6:08, OffenseTeamId: 1610612766> <Possession GameId: 0020000019, Period: 3, Number: 23, StartTime: 5:47, EndTime: 5:28, OffenseTeamId: 1610612762> <Possession GameId: 0020000019, Period: 4, Number: 41, StartTime: 1:33, EndTime: 1:20, OffenseTeamId: 1610612747> <Possession GameId: 0020000020, Period: 3, Number: 20, StartTime: 7:18, EndTime: 6:52, OffenseTeamId: 1610612760>

Since I'm a new nba audience, I don't know the rules very well, is there such a situation that the defense team makes a free throw due to a foul by the offense team but does not exchange the ball. I notice that in Game 0020000017 UTA made a freethrow in when LAL is the offense team.

dblackrun commented 2 years ago

I'm guessing your issue is how you are dealing with technical free throws. There is no change of possession, so the free throw from the technical foul can be shot by either the team on offence or defence, depending on who had the ball when the technical foul was called.