cwendt94 / espn-api

ESPN Fantasy API! (Football, Basketball)
MIT License
544 stars 183 forks source link

NFL position mapping incorrect #460

Open BrianPaur opened 10 months ago

BrianPaur commented 10 months ago

Sport

Football

Summary

I believe the position mapping for Kickers is off on the football->constant.py. I believe 5 should be 'K' not 'TE/WR'. Let me know if I'm wrong on this. My kicker kept coming back as the wrong position when pulled through. Hoping it wasn't just user error... Looks like you have 17 listed as a kicker but none of the players I have in my league come back as a 17. So I can't pinpoint what that is.

image

Logs/Data

No response

BrianPaur commented 10 months ago

Looks like TE is mapped incorrectly as well. image

BrianPaur commented 10 months ago

These are after I updated the constant.py

dtcarls commented 10 months ago

Can you provide how you are getting an incorrect position? I am not having any issues with the following.

box_scores = league.box_scores()

for box in box_scores:
    for i in box.away_lineup:
        if i.slot_position == 'TE' or i.slot_position == 'K':
            print(i.eligibleSlots)
            print(i.name)
BrianPaur commented 10 months ago

yeah, definitely. I'm kind of breaking this apart to get the data I need.

I used the get_league() function in the espn_requests.py file to pull the JSON data. When I do that the defaultPositionId doesn't match up. Which maybe that's the incorrect line item to be looking for. It looks like the position mapping in constant is using the eligibleSlots.

I tried googling to see if ESPN had any docs on it without any luck. But the below code is an example of what George Kittle's line data looks like.

from espn_api.requests.espn_requests import EspnFantasyRequests

def test():
    league = League(lg_id, year, espn_s2=espn_s2, swid=swid)

    espnrequest = EspnFantasyRequests(sport='nfl', year=year, league_id=lg_id, cookies=None,
                                      logger=Logger(name='nfl league', debug=False)).get_league()

    team_extract = {key: espnrequest[key] for key in espnrequest.keys()
                    & {'teams'}}

   # Below is specific for my league. I knew Kittle was on team one (position 0) and in entries at position 4. 
    print(team_extract['teams'][0]['roster']['entries'][4]['playerPoolEntry']['player'])

test()
{'active': True, 'defaultPositionId': 4, 'draftRanksByRankType': {'STANDARD': {'auctionValue': 6, 'published': False, 'rank': 79, 'rankSourceId': 0, 'rankType': 'STANDARD', 'slotId': 0}, 'PPR': {'auctionValue': 6, 'published': False, 'rank': 79, 'rankSourceId': 0, 'rankType': 'PPR', 'slotId': 0}}, 'droppable': True, 
'eligibleSlots': [5, 6, 23, 7, 20, 21], 'firstName': 'George', 
'fullName': 'George Kittle', 'id': 3040151, 'injured': False, 'injuryStatus': 'QUESTIONABLE', 'lastName': 'Kittle', 'lastNewsDate': 1694203004000, 'lastVideoDate': 1694014587000, 'outlooks': {'outlooksByWeek': {'1': "Kittle begins Week 1 with a questionable label. Assuming he dons the pads for the 49ers Week 1 opener in Pittsburgh, the veteran tight end remains one of the best players at the position. He's an automatic fantasy starter, despite facing a tough defense on the road."}}, 'ownership': {'auctionValueAverage': 9.952864803838555, 'averageDraftPosition': 56.45442761727681, 'percentChange': 0.1892069953279787, 'percentOwned': 98.91212533631992, 'percentStarted': 85.1987250255149}, 'proTeamId': 25, 'rankings': {'0': [{'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 9, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 7, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 7, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 7, 'rankSourceId': 5, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 6, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 6, 'rankSourceId': 5, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 7, 'rankSourceId': 3, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 10, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 7, 'rankSourceId': 3, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 6, 'rankSourceId': 11, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'averageRank': 6.25, 'published': True, 'rank': 0, 'rankSourceId': 0, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'averageRank': 5.5, 'published': True, 'rank': 0, 'rankSourceId': 0, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 6, 'rankSourceId': 11, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 12, 'rankType': 'PPR', 'slotId': 6}], '1': [{'auctionValue': 0, 'published': True, 'rank': 4, 'rankSourceId': 9, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 7, 'rankSourceId': 7, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 7, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 4, 'rankSourceId': 5, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 4, 'rankSourceId': 6, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 5, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 6, 'rankSourceId': 3, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 10, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 6, 'rankSourceId': 3, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 5, 'rankSourceId': 11, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'averageRank': 5.25, 'published': True, 'rank': 0, 'rankSourceId': 0, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'averageRank': 4.75, 'published': True, 'rank': 0, 'rankSourceId': 0, 'rankType': 'PPR', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 4, 'rankSourceId': 11, 'rankType': 'STANDARD', 'slotId': 6}, {'auctionValue': 0, 'published': True, 'rank': 4, 'rankSourceId': 12, 'rankType': 'PPR', 'slotId': 6}]}, 'seasonOutlook': "Kittle is entering his seventh NFL season in search of his sixth consecutive finish of fourth or better in fantasy PPG. He finished second in 2022, but got quite lucky in the TD department (his TE-high 12.8% TD rate was three times his prior career rate), which overshadowed a concerning 16% target share (4.2 per game) and 10.2 fantasy PPG (would've ranked eighth over the full season) during nine full games with Christian McCaffrey, Deebo Samuel and Brandon Aiyuk. Kittle has some durability concerns, having completed one full regular season (2018) in six tries. He remains a fine TE1 option, but with more target competition than ever before, it's possible the 29-year-old settles in as more of a midrange starter than the top-end play he's been in recent years.", 'stats': [{'appliedAverage': 0.0, 'appliedStats': {}, 'appliedTotal': 0.0, 'externalId': '2023', 'id': '002023', 'proTeamId': 0, 'scoringPeriodId': 0, 'seasonId': 2023, 'statSourceId': 0, 'statSplitTypeId': 0, 'stats': {}}, {'appliedAverage': 11.141618877666666, 'appliedStats': {'53': 62.16964118, '72': -0.839027788, '24': 1.102566341, '25': 0.977356278, '26': 0.011857238, '42': 72.58478701, '43': 30.490930368, '44': 0.606263854, '63': 0.019908684}, 'appliedTotal': 167.12428316499998, 'externalId': '2023', 'id': '122023', 'proTeamId': 0, 'scoringPeriodId': 0, 'seasonId': 2023, 'statSourceId': 1, 'statSplitTypeId': 2, 'stats': {'23': 2.38979158, '24': 11.02566341, '25': 0.162892713, '26': 0.005928619, '27': 2.0, '28': 1.0, '35': 0.004388366, '36': 0.003071856, '37': 0.000234436, '38': 8e-06, '39': 4.613650624, '40': 0.729324039, '42': 725.8478701, '43': 5.081821728, '44': 0.303131927, '45': 0.223302876, '46': 0.145928429, '47': 145.0, '48': 72.0, '49': 36.0, '50': 29.0, '51': 14.0, '53': 62.16964118, '54': 12.0, '55': 6.0, '56': 1.068544619, '57': 0.033047772, '58': 86.88270072, '60': 11.67527842, '61': 48.01328323, '62': 0.309060546, '63': 0.003318114, '66': 0.027915083, '67': 0.726201707, '68': 0.75411679, '70': 0.012840938, '71': 0.406672956, '72': 0.419513894, '73': 0.419513894, '210': 15.11764706, '212': 2.710899079, '213': 35.11487471}}, {'appliedStats': {'53': 4.15919435, '72': -0.055880004, '24': 0.05881986460000001, '25': 0.045672564, '26': 0.00056259, '42': 4.622661245, '43': 1.617588546, '44': 0.032650812, '63': 0.001326}, 'appliedTotal': 10.4825959676, 'externalId': '20231', 'id': '1120231', 'proTeamId': 0, 'scoringPeriodId': 1, 'seasonId': 2023, 'statSourceId': 1, 'statSplitTypeId': 1, 'stats': {'23': 0.136469496, '24': 0.588198646, '25': 0.007612094, '26': 0.000281295, '35': 0.000250588, '36': 0.000175412, '37': 1.08e-05, '38': 3.69e-07, '39': 4.31011079, '40': 1.176397292, '42': 46.22661245, '43': 0.269598091, '44': 0.016325406, '45': 0.010619836, '46': 0.006940063, '47': 9.0, '48': 4.0, '49': 2.0, '50': 1.0, '53': 4.15919435, '56': 0.077843597, '57': 0.00241, '58': 5.818823713, '60': 11.11431892, '61': 92.4532249, '62': 0.016606701, '63': 0.000221, '66': 0.001594096, '67': 0.048583424, '68': 0.05017752, '70': 0.000733284, '71': 0.027206717, '72': 0.027940002, '73': 0.027940002, '210': 0.5, '212': 0.155708253, '213': 2.265379065}}, {'appliedAverage': 13.366666666666667, 'appliedStats': {'53': 60.0, '72': -2.0, '42': 76.5, '43': 66.0}, 'appliedTotal': 200.5, 'externalId': '2022', 'id': '002022', 'proTeamId': 0, 'scoringPeriodId': 0, 'seasonId': 2022, 'statSourceId': 0, 'statSplitTypeId': 0, 'stats': {'41': 60.0, '42': 765.0, '43': 11.0, '45': 1.0, '46': 1.0, '47': 145.0, '48': 69.0, '49': 33.0, '50': 22.0, '51': 6.0, '52': 1.0, '53': 60.0, '54': 4.0, '56': 1.0, '58': 86.0, '59': 382.0, '60': 12.75, '61': 51.0, '67': 1.0, '68': 1.0, '71': 1.0, '72': 1.0, '73': 1.0, '106': 1.0, '108': 3.0, '109': 3.0, '155': 12.0, '156': 3.0, '158': 66.0, '183': 4.0, '184': 1.0, '185': 1.0, '186': 4.0, '210': 15.0, '213': 37.0}}, {'appliedAverage': 11.863612998428573, 'appliedStats': {'53': 61.14929679, '72': -0.826082474, '24': 1.121125334, '25': 1.0131271320000002, '26': 0.012292592, '42': 71.48396648, '43': 31.490998878, '44': 0.626251634, '63': 0.019605612}, 'appliedTotal': 166.09058197800002, 'externalId': '2023', 'id': '102023', 'proTeamId': 0, 'scoringPeriodId': 0, 'seasonId': 2023, 'statSourceId': 1, 'statSplitTypeId': 0, 'stats': {'23': 2.427341673, '24': 11.21125334, '25': 0.168854522, '26': 0.006146296, '27': 2.0, '28': 1.0, '35': 0.004457411, '36': 0.003120188, '37': 0.000243857, '38': 8.3219e-06, '39': 4.618737225, '40': 0.766967029, '42': 714.8396648, '43': 5.248499813, '44': 0.313125817, '45': 0.222982383, '46': 0.145718987, '47': 142.0, '48': 71.0, '49': 35.0, '50': 28.0, '51': 14.0, '53': 61.14929679, '54': 12.0, '55': 6.0, '56': 1.025914405, '57': 0.031729311, '58': 85.60455238, '60': 11.69007171, '61': 48.90251228, '62': 0.319272113, '63': 0.003267602, '66': 0.028353705, '67': 0.714283095, '68': 0.7426368, '70': 0.013042704, '71': 0.399998533, '72': 0.413041237, '73': 0.413041237, '210': 14.61764706, '212': 2.72389141, '213': 34.64689872}}, {'appliedAverage': 12.113741960285713, 'appliedStats': {'53': 62.72217712, '72': -0.97486241, '24': 1.083760818, '25': 0.9251236740000001, '26': 0.008921712, '42': 77.68872161000002, '43': 27.641816532, '44': 0.473602492, '63': 0.023125896}, 'appliedTotal': 169.592387444, 'externalId': '2022', 'id': '102022', 'proTeamId': 0, 'scoringPeriodId': 0, 'seasonId': 2022, 'statSourceId': 1, 'statSplitTypeId': 0, 'stats': {'23': 2.315084271, '24': 10.83760818, '25': 0.154187279, '26': 0.004460856, '27': 2.0, '28': 1.0, '35': 0.004251338, '36': 0.002975936, '37': 0.000242836, '38': 8.29e-06, '39': 4.681301806, '40': 0.767663913, '42': 776.8872161, '43': 4.606969422, '44': 0.236801246, '45': 0.243068183, '46': 0.158845058, '47': 155.0, '48': 77.0, '49': 38.0, '50': 31.0, '51': 15.0, '53': 62.72217712, '54': 12.0, '55': 6.0, '56': 1.427261126, '57': 0.044142097, '58': 89.50325955, '60': 12.3861647, '61': 55.02951114, '62': 0.241262102, '63': 0.003854316, '66': 0.031181662, '67': 0.844799359, '68': 0.875981021, '70': 0.014343564, '71': 0.473087641, '72': 0.487431205, '73': 0.487431205, '210': 14.11764706}}], 'universeId': 2}

This is what I get back when I run your code for my league. It isn't incorrect it just looks weird when using the eligible slots. Why is it mapped as 'WR/TE' and not just 'TE' for most TEs? When I go to the ESPN website they just have him as a TE.

['WR/TE', 'TE', 'RB/WR/TE', 'OP', 'BE', 'IR']
Pat Freiermuth

['K', 'BE', 'IR']
Evan McPherson

['WR/TE', 'TE', 'RB/WR/TE', 'OP', 'BE', 'IR']
George Kittle

['K', 'BE', 'IR']
Harrison Butker

['WR/TE', 'TE', 'RB/WR/TE', 'OP', 'BE', 'IR']
Gerald Everett

['K', 'BE', 'IR']
Cameron Dicker

['WR/TE', 'TE', 'RB/WR/TE', 'OP', 'BE', 'IR']
Kyle Pitts

['K', 'BE', 'IR']
Jason Myers

['WR/TE', 'TE', 'RB/WR/TE', 'OP', 'BE', 'IR']
Evan Engram

['K', 'BE', 'IR']
Daniel Carlson

['K', 'BE', 'IR']
Justin Tucker

['WR/TE', 'TE', 'RB/WR/TE', 'OP', 'BE', 'IR']
David Njoku

image

DesiPilla commented 8 months ago

@BrianPaur the eligibleSlots refers not to the NFL slots, but rather the fantasy slots that the player is eligible for. For example, Pat Freiermuth is a TE, and only a TE. His eliebleSlots appear as ['TE', 'BE', 'IR', 'WR/TE', 'RB/WR/TE', 'OP'] because in your fantasy lineup, you can put a TE

So, it's not saying that the NFL has defined Freiermuth as a WR/TE. Instead, it's saying that as a TE, Freiermuth is eligible to played in the WR/TE slot. I hope this answers your question (after nearly 2 months)