Updating only one side / half of a game -- any best practices?

33 views
Skip to first unread message

Brian Goodness

unread,
Oct 24, 2021, 1:49:37 PM10/24/21
to SDQL API
Hi Joe,

I've been adding in some NBA data (e.g., game number, site streak, rest) and have been running into some issues with updating the fields, only for when the t:team is away (i.e., t:site=away).

I have two follow-up questions to your response in this thread (https://groups.google.com/g/sdqlapi/c/NA3czR4YRCQ/m/4-QrAsSZBQAJ):

(1) You might have already answered this in the referenced thread, but just to confirm, is there any way to update only one half/side of a game-- in particular, when the team is away-- without having to include stats for both the home and away teams in the same row/dict? (The stats for the home team seem to update fine when not also including stats for the away team.)

For instance, would it be possible to use the following dict structure to update the stats for the 2021-10-27 / 't:team': 'Timberwolves / 'o:team':'Bucks' game (as highlighted in attached screenshot)? (Note, the Timberwolves was the away team for that game.)

data_dict = {
    'date': 20211027,
    't:team': 'Timberwolves',
    'o:team': 'Bucks',
    't:game number': 4,
    't:rest': '1',
    't:site streak': 3,
    'venue name': 'Fiserv Forum',
    'venue city': 'Milwaukee',
    'venue state': 'WI',
    'venue capacity': 17341,
    'data datetimestamp': '2021-10-23 01:08:06'
}


https://s3.sportsdatabase.com/NBA/query.html?sdql=date%2C+t%3Agame+number%2C+team%2C+o%3Ateam%2C+o%3Agame+number%2C+t%3Asite+streak%2C+site%2C+o%3Asite+streak%2C+t%3Arest%2C+o%3Arest%2C+data+datetimestamp+%40+season%3D2021+and+date%3D20211027&submit=++S+D+Q+L+%21++

Screenshot from 2021-10-24 08-29-00.png

If it is not possible to update stats for the away team without also providing stats for the both sides/halves of the game (i.e., stats for both the home and away teams), then this won't be an issue, I am able to reconfigure my data to include both sides, I just wanted to confirm this indeed is the case. (The approach of including stats for both home and away sides in one row already worked for me, when testing on games for earlier in the 2021 season.)


(2) If stats for both sides/halves of a game must be included in order to update the second/opponent side (i.e., "o:" side) of the game, then, can you recommend a good way to clearly know which team is the "t:" side, and which team the "o:" team, in a game/row of the database?

I could make the assumption that the home team will always be the 't:' team/side, and the away team always the 'o:' team/side and this should work most of the time. However, this is not necessarily a good assumption all the time: some games are played at a neutral site, or, I could foresee there being instances when the home='t:' and away='o:' heuristic doesn't happen to be strictly followed (i.e., if the sides are inadvertently switched). For these edge cases, I guess I could always just use trial and error.

If you do have any insight/advice on a best practice for identifying the "t:" side of a game in the database (or if there is a good way to update only one side of a game when the team is away, without having to provide the fields for both sides), I'd appreciate it.

Thanks for all of your great work over the years and support during this transition.

Thanks, and have a good weekend.

--Brian


Joe Meyer

unread,
Oct 24, 2021, 2:31:48 PM10/24/21
to sdq...@googlegroups.com
Brian and API Friends,

by convention `t:team` is the home team or the bottom team in the box score for neutral sites.

To update a stat for the opponent, the corresponding t:stat is required.   

You could do:
...
"t:stat":None,
"o:stat",4
...

Best regards,

Joe Meyer
Sports Database LLC



--

---
You received this message because you are subscribed to the Google Groups "SDQL API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sdqlapi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sdqlapi/8dfd4234-91d4-48c3-8446-b8a34e50fd50n%40googlegroups.com.

Brian Goodness

unread,
Oct 24, 2021, 6:23:45 PM10/24/21
to SDQL API
Joe,

Thank you for clarifying the convention used for the `t:team` side of each game in the database, this is great info to know for going forward.

Also, good to know that stats on the 't:' side of a game can be populated with None in order to only update a stat on the opponent ('o:') side of the game. Using this method provided in your example, would the None overwrite stats on the 't:' side of the game, or, would it just skip over those stats for the 't:' side?

Thanks again,
Brian

John Currey

unread,
Oct 30, 2021, 8:15:37 AM10/30/21
to SDQL API
Joe, 

I see that the rule is the "t:" side is required. I don't want to doubt the master, but I've been updating the "o:" without the "t:" without issue. It seems to work just fine. Here's my dictionary:

Oct30.PNG
Here's the data successfully imported:

I've used this every week and it worked fine until I got stuck on a week 5 game I entered incorrectly. Is it best to always have a "t:" side or is this a reasonable approach?

Thanks.
Reply all
Reply to author
Forward
0 new messages