dynastyprocess / data

An open-data fantasy football repository, maintained by DynastyProcess.com
https://dynastyprocess.com
GNU General Public License v3.0
73 stars 19 forks source link

Adding missing ESPN ID's to Player ID's map #38

Closed TheMathNinja closed 1 year ago

TheMathNinja commented 2 years ago
remotes::install_github("dfs-with-r/ffespn")

library(ffscrapr)
library(ffespn)
library(tidyverse)

#Build df listing all ESPN position designations at current moment.
espnqblist_2022 <- ffespn_projections(2022, 0, "QB", league_id = espn_league_id_2022) %>%
  select(id:position)
espnrblist_2022 <- ffespn_projections(2022, 0, "RB", league_id = espn_league_id_2022) %>%
  select(id:position)
espnwrlist_2022 <- ffespn_projections(2022, 0, "WR", league_id = espn_league_id_2022) %>%
  select(id:position)
espntelist_2022 <- ffespn_projections(2022, 0, "TE", league_id = espn_league_id_2022) %>%
  select(id:position)
espnpklist_2022 <- ffespn_projections(2022, 0, "K", league_id = espn_league_id_2022) %>%
  select(id:position)
espnpnlist_2022 <- ffespn_projections(2022, 0, "P", league_id = espn_league_id_2022) %>%
  select(id:position)
espndtlist_2022 <- ffespn_projections(2022, 0, "DT", league_id = espn_league_id_2022) %>%
  select(id:position)
espndelist_2022 <- ffespn_projections(2022, 0, "DE", league_id = espn_league_id_2022) %>%
  select(id:position)
espnlblist_2022 <- ffespn_projections(2022, 0, "LB", league_id = espn_league_id_2022) %>%
  select(id:position)
espncblist_2022 <- ffespn_projections(2022, 0, "CB", league_id = espn_league_id_2022) %>%
  select(id:position)
espnslist_2022 <- ffespn_projections(2022, 0, "S", league_id = espn_league_id_2022) %>%
  select(id:position)

espnlist_2022 <- bind_rows(espnqblist_2022,
                           espnrblist_2022,
                           espnwrlist_2022,
                           espntelist_2022,
                           espnpklist_2022,
                           espnpnlist_2022,
                           espndtlist_2022,
                           espndelist_2022,
                           espnlblist_2022,
                           espncblist_2022,
                           espnslist_2022) %>%
  rename(espn_id = id,
         espn_pos = position,
         espn_team = team)

#Update ffscrapr's ESPN ID's by building df w/ missing IDs (usually rookies)
espn_id_adds <- dp_playerids() %>%
  rename(dp_espn_id = espn_id,
         player = name) %>%
  full_join(., y = espnlist_2022,
            by = c("player")) %>%
  select(player,
         position,
         espn_pos,
         team,
         espn_team,
         dp_espn_id,
         espn_id) %>%
  filter(espn_id %in% dp_espn_id == FALSE)

yields 228 updates to ESPN ID's ("OAK" Sam Williams needs no updating). Please add!

tanho63 commented 2 years ago

Adding to backlog as a feature request.

If you want to help, you'll need to (figure out how to) map the ESPN IDs in question to an MFL ID and then update this CSV with a PR: https://github.com/dynastyprocess/data/blob/master/files/missing_ids.csv

I probably will not have time to look at this in the near future.

TheMathNinja commented 2 years ago

dp_missing_ids_update_2022.csv

I've got the new CSV here. Would you be willing to do the pull?

TheMathNinja commented 2 years ago

I'll attempt it but something tells me it might not go right.