df_teams <- read_csv("https://bcdanl.github.io/data/mlb_team_seasons.csv")Baseball
Explore the data on a map
Explore the project data by location. Select a location for details.
Loading the map…
Data
On-page tables preview a sample of rows. Download the files to analyze the complete datasets.
Download CSV files:
- MLB team seasons
- MLB batting seasons
- MLB pitching seasons
- Player identifiers
- Historical player salaries
- Historical team payrolls
- Historical postseason series
Updated October 6, 2026. Each main download contains historical and current records together. Team seasons and player seasons cover 1985–2026, using the latest Lahman database through 2025 and official MLB statistics for 2026. These files contain regular-season statistics. The 2026 regular season is complete; the postseason is still underway.
Historical player-team stints have been summed into one player per season before adding the 2026 totals. The full historical batting source was collected again, including stints with fewer than 100 at-bats. Batting records include players with at least one at-bat, walk, hit by pitch, or sacrifice; defensive-only appearances with no recorded batting opportunity are excluded. Apply a playing-time filter after importing the combined data, so short batting stints do not disappear from a player’s season totals.
MLB team seasons (df_teams)
1,218 rows, one per team-season.
season identifies the year. teamID retains the Lahman team code, and franchID identifies the franchise through relocations and name changes. mlb_team_id is MLB’s numeric franchise identifier. Team names can change over time; join or group using an identifier.
| Variables | Meaning |
|---|---|
G, W, L, winning_percentage |
Games, wins, losses, and wins divided by decisions |
R, RA |
Runs scored and runs allowed |
AB, H, X1B, X2B, X3B, HR, TB |
At-bats, hits, singles, doubles, triples, home runs, and total bases |
BB, HBP, SO, SB, CS |
Walks, hit by pitch, strikeouts, stolen bases, and caught stealing |
RC |
Runs Created, computed with the same formula in every year |
IPouts, ER, ERA |
Pitching outs, earned runs, and earned runs per nine innings |
Rank, DivWin |
Division position and division champion |
name, park, attendance |
Team name, home park, and attendance |
History-only fields such as attendance, park factors, and World Series outcome remain blank for 2026 when they are unavailable from the current source. Blank values do not mean zero.
MLB player batting seasons (df_battings)
36,053 rows, one per player-season, including all team stints.
df_battings <- read_csv("https://bcdanl.github.io/data/mlb_batting_seasons.csv")| Variables | Meaning |
|---|---|
season, player_key, player |
Year, common player identifier, and full name |
G, AB, R, H, RBI |
Games, at-bats, runs, hits, and runs batted in |
X1B, X2B, X3B, HR, TB |
Singles, doubles, triples, home runs, and total bases |
BB, IBB, HBP, SO |
Walks, intentional walks, hit by pitch, and strikeouts |
SB, CS, SH, SF, GIDP |
Stolen bases, caught stealing, sacrifice bunts, sacrifice flies, and double plays grounded into |
AVG, OBP, SLG, OPS |
Batting average, on-base percentage, slugging percentage, and OBP plus SLG |
BB_HBP, RC |
Walks plus hit by pitch and Runs Created |
teams, leagues, team_stints |
Historical team codes, leagues, and stint count |
The 2026 API reports overall season totals and does not provide the list of all team stints in that response, so teams, leagues, and team_stints are blank for 2026. G includes defensive appearances in the official current batting source; AB is the useful exposure measure for batting analyses. BB already includes IBB.
Rates are recalculated from season counts rather than averaging stint rates:
AVG=H/AB, \qquad OBP=(H+BB+HBP)/(AB+BB+HBP+SF)
TB=H+X2B+2X3B+3HR, \qquad SLG=TB/AB.
For example, select a common minimum number of at-bats after reading the file:
batting_sample <- df_battings |> filter(AB >= 100)MLB player pitching seasons (df_pitchings)
26,722 rows, one per pitcher-season, including all team stints.
df_pitchings <- read_csv("https://bcdanl.github.io/data/mlb_pitching_seasons.csv")| Variables | Meaning |
|---|---|
W, L, G, GS, CG, SHO, SV |
Wins, losses, games, starts, complete games, shutouts, and saves |
IPouts, innings |
Outs recorded and numeric innings (IPouts / 3) |
H, ER, R, HR, BB, SO |
Hits allowed, earned runs, total runs allowed, home runs, walks, and strikeouts |
ERA |
27 * ER / IPouts |
WHIP |
3 * (H + BB) / IPouts |
KperBB, Kper9, BBper9 |
Strikeouts divided by all walks, strikeouts per nine innings, and walks per nine innings |
BFP, GF, IBB, WP, HBP, BK |
Batters faced, games finished, intentional walks, wild pitches, hit batters, and balks |
innings is an ordinary numeric quantity. It avoids baseball’s 6.2 notation, which means six innings and two outs. Rates with a zero denominator are blank. Historical opponent batting average was dropped because the at-bat denominator needed to combine stint averages accurately is unavailable.
Player identities (df_players)
24,525 player identities, including the newest players, with names and available biographical details.
df_players <- read_csv("https://bcdanl.github.io/data/mlb_player_ids.csv")player_key is the common identifier in the combined batting and pitching files. Historical Lahman IDs were linked to MLB IDs using the Chadwick Baseball Bureau register, with exact Baseball-Reference identifier cross-references. A matched key starts with mlbam:; an unmapped historical key starts with lahman:. A name match alone was not used to identify a player.
lahman_player_id supports joins to the historical salary file’s playerID. It can be blank for new players. mlbam_id is MLB’s identifier. Use either field only with its matching source.
pitching_with_names <- df_pitchings |>
left_join(df_players |> select(player_key, birth_date, bats, throws),
by = "player_key", relationship = "many-to-one")Salaries, payrolls, and postseason series
These datasets already combine all available years in one file per type. Salaries and payrolls cover 1985–2016, the latest years in Lahman’s salary release. They support historical salary analyses; current salaries are unavailable in that source. Payroll is in millions of US dollars; individual salary is in US dollars.
df_salaries <- read_csv("https://bcdanl.github.io/data/mlb_salaries.csv")
df_salariesTeam <- read_csv("https://bcdanl.github.io/data/mlb_payrolls.csv")
df_postseasons <- read_csv("https://bcdanl.github.io/data/mlb_postseasons.csv")Postseason series cover the source’s full history through 2025. Each series has winning and losing team codes, wins, losses, and ties. The incomplete 2026 postseason is omitted.
Every combined season file includes source, source_url, retrieved_date, and season_status. The original source files remain available as archives, but use the combined downloads above for comparisons across years.
Sabermetrics
Baseball analysis underwent a significant transformation with Bill James’s pioneering work in the late 1970s. Through his publication, the Bill James Baseball Abstract, James challenged the reliance on traditional metrics like batting average, runs, and RBIs for hitters, and wins, ERA, and strikeouts for pitchers. Instead, he introduced innovative metrics such as runs created, Pythagorean win percentage, and game score. He called this analytical framework sabermetrics, named after the Society for American Baseball Research (SABR). While initially dismissed by traditionalists as secondary to the expertise of seasoned “baseball people,” James’s methods have become foundational in modern baseball. Today, every Major League Baseball team employs analytics experts who utilize advanced mathematics, predictive modeling, and optimization techniques to assemble competitive teams and make in-game decisions aimed at maximizing success.
For many, the 2011 movie Moneyball provides the most accessible introduction to sports analytics. The film recounts how the Oakland A’s used data-driven insights during their 2002 season, despite skepticism from traditional scouts who mocked Bill James’s ideas. Since that era, analytics have not replaced scouts but have become an essential complement, with every team now leveraging sophisticated data analyses alongside traditional evaluations.
Baseball Metrics
Historical Metrics
For over a century, baseball players were evaluated using a limited set of straightforward offensive and defensive statistics. However, advancements in computing and the introduction of sabermetrics revolutionized how player performance is assessed, giving rise to more nuanced and meaningful metrics.
Offensive Statistics
| Statistic | Definition |
|---|---|
| Batting Average | Hits divided by at-bats (Hits ÷ At-Bats) |
| Home Runs | Total number of home runs hit by a player |
| Runs Batted In (RBI) | Number of runs a player has batted in |
| Walks | Number of times a batter reaches first base via four balls (also known as Base on Balls) |
| On Base Percentage (OBP) | Times on base (hits + walks + hit by pitch) divided by plate appearances |
| Runs Scored | Number of times a player crosses home plate to score a run |
| Slugging Percentage (SLG) | Total bases divided by at-bats (Total Bases ÷ At-Bats) |
Defensive Statistics
| Statistic | Definition |
|---|---|
| Wins | Credited to the pitcher who was pitching when his team took the lead for good |
| Innings Pitched | Total number of innings a pitcher has pitched |
| Earned Run Average (ERA) | Average number of earned runs a pitcher allows per nine innings pitched |
| Walks | Number of batters a pitcher has allowed to reach first base via four balls |
| Strikeouts | Number of batters a pitcher has retired by striking them out |
| WHIP | Walks plus hits per inning pitched ((Walks + Hits) ÷ Innings Pitched) |
| Saves | Credited to a pitcher who finishes a game for the winning team under certain conditions |
| Fielding Percentage | Percentage of times a defensive player handles the ball without making an error |
Runs Created
One of Bill James’s original metrics, Runs Created (RC), estimates the number of runs a player or team contributes to scoring. The formula is:
RC = \frac{(H + BB + HBP) \times TB}{AB + BB + HBP}
Where:
- H = Hits
- BB = Walks (Base on Balls)
- HBP = Hit by Pitch
- TB = Total Bases
- AB = At-Bats
This metric helps evaluate a player or team’s offensive value. For example, if considering adding a player to a team, comparing their runs created to other candidates provides a data-driven basis for decision-making.
