FantasyBaseballTrends¶
Functions¶
setUpWebsite¶
- FantasyBaseballTrends.setUpWebsite()¶
Before using any function in this library, run this first to set up the website! This function sets up baseball-reference and returns the browser.
searchPlayer¶
- FantasyBaseballTrends.searchPlayer(browser, player)¶
A function to search for a given player on the website.
- Parameters
browser (webdriver) – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
Url of the players home stats page
get2023Season¶
- FantasyBaseballTrends.get2023Season(browser, player)¶
A function that retrieves the current 2023 Stats for a player. Returns a pandas DataFrame that contains the information from the 2023 stats table on baseball-reference.
- Parameters
browser – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
contains the season stats
- Return type
pandas.DataFrame
getLastGame¶
- FantasyBaseballTrends.getLastGame(browser, player)¶
A function that retrieves a players last game stats. Returns a pandas DataFrame that contains the stats from a players last game.
- Parameters
browser – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
contains a players last game stats
- Return type
pandas.DataFrame
getVsRhpCurrent¶
- FantasyBaseballTrends.getVsRhpCurrent(browser, player)¶
A function that retrieves a players current season stats against right handed pitching. Returns a pandas DataFrame that contains a players current season stats against right handed pitching.
- Parameters
browser – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
contains stats against all right handed pitchers split by starter and reliever
- Return type
pandas.DataFrame
getVsLhpCurrent¶
- FantasyBaseballTrends.getVsLhpCurrent(browser, player)¶
A function that retrieves a players current season stats against left handed pitching. Returns a pandas DataFrame that contains a players current season stats left right handed pitching.
- Parameters
browser – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
contains stats against all left handed pitchers split by starter and reliever
- Return type
pandas.DataFrame
getCareerSplits¶
- FantasyBaseballTrends.getCareerSplits(browser, player)¶
A function that retrieves a players career stats against all pitching. Returns a pandas DataFrame that contains a players career stats against all pitching.
- Parameters
browser (webdriver) – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
each row represents stats against different handed starting pitchers and all pitchers
- Return type
pandas.DataFrame
getLastxGames¶
- FantasyBaseballTrends.getLastxGames(browser, player, gamesNum)¶
A function that retrieves a players stats over gamesNum amount of games. Returns a pandas DataFrame that contains a players stats in each of the last games.
- Parameters
browser (webdriver) – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
gamesNum (int) – how many games do retrieve stats for
- Returns
each row represents stats a game with their latest game as the last row
- Return type
pandas.DataFrame
getAvgOverLastXGames¶
- FantasyBaseballTrends.getAvgOverLastxGames(browser, player, gamesNum)¶
A function that retrieves the players avg stats over ‘gamesNum’ amount of games. Returns a pandas DataFrame that contains a players avg stats over the last games.
- Parameters
browser (webdriver) – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
gamesNum (int) – how many games do retrieve stats for
- Returns
shows the average of that stat over specified number of games
- Return type
pandas.DataFrame
getPostseasonStats¶
- FantasyBaseballTrends.getPostseasonStats(browser, player)¶
A function that retrieves the Postseason stats for a player. Returns a pandas DataFrame that contains the information from the postseason stats section on baseball-reference.
- Parameters
browser – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
contains the postseason stats
- Return type
pandas.DataFrame
getCareer¶
- FantasyBaseballTrends.getCareer(browser, player)¶
A function that retrieves the career stats for a player. Returns a pandas DataFrame that contains the information from the career stats table on baseball-reference.
- Parameters
browser – the browser that you are using, returned by setUpWebsite
player (str) – the player whose stats you are trying to retrieve
- Returns
contains the career stats
- Return type
pandas.DataFrame