Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ncaa_team_player_stats() no Height & Handedness columns #342

Open
jjbishop1344 opened this issue Jun 16, 2024 · 1 comment
Open

ncaa_team_player_stats() no Height & Handedness columns #342

jjbishop1344 opened this issue Jun 16, 2024 · 1 comment

Comments

@jjbishop1344
Copy link

When attempting to pull player data using the ncaa_team_player_stats() function, it appears that the function is pulling player heights and handedness without a proper column to place this data. It is causing the rest of the columns pulled to be offset by two:

ncaa_team_player_stats(193,year=2024, type="batting")
2024-06-16 16:47:42.863319: Invalid arguments provided
# Player Yr Pos GP GS BA OBPct SlgPct R AB H 2B 3B TB HR RBI BB HBP SF SH K OPP DP CS Picked SB IBB GDP
1 29 AJ Gracia Fr UT 6-3 L/L 60 60 0.305 0.440 0.559 56 220 67 14 NA 123 14 58 48 7 2 1 55 3 1 1 5
2 13 Devin Obee Jr OF 6-2 R/R 60 60 0.309 0.399 0.599 57 217 67 11 2 130 16 50 29 7 5 NA 60 3 4 NA 6
3 23 Logan Bravo Sr INF 6-5 R/R 60 60 0.315 0.432 0.630 59 219 69 16 1 138 17 59 43 6 5 NA 62 3 3 NA 9
4 5 Alex Stone Sr C 6-5 R/R 60 60 0.312 0.365 0.547 45 247 77 19 NA 135 13 59 11 12 4 NA 48 9 NA NA NA
5 7 Wallace Clark Jr INF 6-0 B/R 60 60 0.285 0.451 0.446 44 186 53 11 2 83 5 42 37 24 6 5 48 3 2 1 5

Screenshot 2024-06-16 at 4 48 11 PM

Results in a column full of "NAs" meaning that manipulating the dataframe using a package like dplyr is not possible.

@greggmorris22
Copy link

I used this code to correct the error:

`#Assuming your data frame is named 'df'

#Determine the number of columns
num_cols <- ncol(df)

#Calculate the starting and ending indices for the columns to be shifted
start_shift <- 5 # Starting column for shifting
end_shift <- num_cols - 2 # Ending column for shifting

#Extract the incorrect column names
incorrect_names <- colnames(df)[start_shift:end_shift]

#Create a vector of shifted names (shift by 2 positions)
shifted_names <- c(tail(incorrect_names, 2), head(incorrect_names, -2))

#Rename the columns
colnames(df)[start_shift:end_shift] <- shifted_names

#Rename columns 5 and 6 explicitly
colnames(df)[5] <- "Height"
colnames(df)[6] <- "B/T"

#View the corrected data frame
head(df)`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants