Git Product home page Git Product logo

Comments (7)

toddrob99 avatar toddrob99 commented on August 30, 2024 1

This is most likely because gameType defaults to R (regular season) and season defaults to current calendar year. Include season=2018 to look up players from last season, and/or gameType=S (I think S is Spring Training but I may be remembering incorrectly).

player = statsapi.lookup_player('nola,', season=2018)

from mlb-statsapi.

seanloosier avatar seanloosier commented on August 30, 2024

changing the season to 2018 or the gameType to works. That saved me a lot of fiddling around, thank you!

from mlb-statsapi.

toddrob99 avatar toddrob99 commented on August 30, 2024

I’ll try to think of a good way to refactor this function so it works prior to the season starting. Unfortunately there is no endpoint to search players from all time, so it has to specify a season at least. In order to make the function more robust I could probably check the season state and default to previous season if it hasn’t started yet for the current calendar year.

from mlb-statsapi.

McFlyin619 avatar McFlyin619 commented on August 30, 2024

wasnt sure if i should add a new issue as mine is similar. Mine happens on last_game, but since it only takes one parameter, teamId, i am unable to add gametype.

from mlb-statsapi.

toddrob99 avatar toddrob99 commented on August 30, 2024

wasnt sure if i should add a new issue as mine is similar. Mine happens on last_game, but since it only takes one parameter, teamId, i am unable to add gametype.

@McFlyin619, this is actually functioning as designed. The last_game() method is pulling the team endpoint, and returning data from the previousSchedule node--not calculating the last game on its own. If that node is missing from the result, or contains no game data, an exception will be raised. The MLB-StatsAPI library does not attempt to catch all exceptions due to missing data in the API results; instead that should be handled by the calling application when needed.

from mlb-statsapi.

McFlyin619 avatar McFlyin619 commented on August 30, 2024

Ahhh, ok. I'll add the previousSchedule to the results. Thank you!

from mlb-statsapi.

toddrob99 avatar toddrob99 commented on August 30, 2024

In v1.5 (publishing in the next day or two) will change the default for lookup_player and lookup_team methods to the latest season based on the season endpoint, rather than the current calendar year. Will not be able to fully test until January, so please submit a new issue if needed.

from mlb-statsapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.