-
Notifications
You must be signed in to change notification settings - Fork 256
Trouble creating custom box score data frame #116
Comments
Can you share some example code? |
Agree with @rneu31, please share your code @WillPanarese. Based on the error message this seems like an error in your use of pandas not a problem with nba_py, although I could be wrong! |
Here is a sample of code below, I know it is messy and probably redundant, but I can create the first Data frame between the two teams, i get the error message on the second dataframe i try to make with player stats. import pandas as pd teamIDs = ['1610612739', '1610612761'] df_team_stats = [] Monday_Games_Teams = pd.concat(df_team_stats) CLE_team_stats = team.TeamGeneralSplits('1610612739', season='2017-18', measure_type='Advanced') CLE_stats = CLE_team_stats.location() cols = list(CLE_stats.columns.values) print(CLE_stats) TOR_stats = TOR_team_stats.location() CLEvsTOR_teams = pd.concat([CLE_stats, TOR_stats]) CLEvsTOR_teams.to_csv("CLEvsTOR_teams.csv") teamIDs = ['1610612739', '1610612761'] df_player_stats = [] Monday_Games_Players = pd.concat(df_player_stats) CLE_Players1 = team.TeamPlayers('1610612739', season='2017-18', measure_type='Advanced') CLE_player_stats = CLE_Players1.season_totals cols = list(CLE_player_stats.columns.values) print(CLE_player_stats) PHO_player_stats = PHO_Players1.season_totals CLEvsPHO_players = pd.concat([CLE_player_stats, PHO_player_stats]) CLEvsPHO_players.to_csv('CLEvsPHO_players.csv') |
my end goal is to try to create a custom box score in an excel spreadsheet like in this article http://blog.yhat.com/posts/visualize-nba-pipelines.html the hope is that I can get all of the statistics I want, then start building an equation combing stats like OFF RTG DEF RTG, PIE, PER, VORP, etc. so I can compare teams playing and try to predict margin. I am just starting to play with this so bear with my mistakes, still learning. |
Hi @WillPanarese, I'm not sure if the output is what you were looking for but I made some edits that get the script to run without an error message: https://pastebin.com/9mYcG9C1 I believe I added comments for each change I made. I suspect there's a lot that could be done to improve your code beyond this but this should help you. |
I have been trying to play around with making a model using this API and have been attempting to create a large dataframe of team and player statistics for any given game. I can create a dataframe that takes all of the advanced statistics from a number of teams and put that into an excel, but when I try to get the advanced statistics for each player from each team, I get the following error:
TypeError: cannot concatenate object of type "<type 'instancemethod'>"; only pd.Series, pd.DataFrame, and pd.Panel (deprecated) objs are valid
let me know if anyone can help.
The text was updated successfully, but these errors were encountered: