Ballpark figures: Analyzing MLB baseball attendance | Domo (2024)

It is springtime in the U.S., which means something as American as apple pie is back: baseball. And since there’s all kinds of great data around one of the country’s great pastimes, we decided for this week’s post to look atMajor League Baseball(MLB) attendance statistics from the last 20 years, which is published on many websites including the one we used to get the data you’ll find in the charts below:ESPN.com.

To collect the attendance data from ESPN, we usedJupyter Workspaces(currently in beta in Domo) and the Python packageBeautiful Soupto parse the HTML.And since Domo can now schedule code in Jupyter Workspaces to run regularly, you can be sure that this page will continue to update with the 2022 data.

The first thing you’ll probably notice when looking at the data is that 2020 is missing. That’s because, due to thepandemic, baseball was played without fans that year.There was a bit of a return to normalcy in 2021, but it wasn’t until this season that all spectating restrictions were lifted, so it will be interesting to watch how attendance rebounds (though, in full transparency, we only have the data for full years right now, so we are not capturing any data related to seasonality, such as how weather or a team’s place in the playoff race affects ticket sales).

One good way to review this data is with an old favorite of many data scientists: abox and whisker plot. The chart shows the minimum and maximum average attendance for each team in the whiskers (the top and bottom lines).I have sorted this to show the team with the highest peak attendance year on the left, and the lowest on the right:

Where the visualization gets more interesting for me is with the box elements.Each box shows the space between the 25th and 75th percentiles, which is meant to reflect how much a team’s attendance has swung over the years.The bigger boxes tell me those teams (such as Philadelphia and Detroit) have had some great years for attendance and some not so great years.Smaller boxes (such as Boston) say that a team has been very consistent in its attendance numbers.We have also filtered the chart for pre-pandemic years only, because 2021—and, to a lesser extent, 2022—skews the data.

An alternative approach to understanding how teams rank in attendance is to create indexes of where a team’s attendance stands relative to the total MLB average—which is what we’ve done directly below.Dark blue boxes mean that a team is well above the average, while dark orange boxes mean that a team is well below the average.You can use the filters to look at whatever league, division, team(s), or year(s) you’re interested in:

Long-time Domo users may be looking at these indexes and thinking that I did some pre-calculation in a Magic ETL or a Dataset View.It’s true that doing calculations on such total levelstypicallyrequire pre-calculation.But if I did that, it would be hard to allow for the year filter.So, the secret is out: With Domo’s new FIXED beast modes (currently in beta), you can do FIXED level of detail functions right in a beast mode.For the above “Index to League Avg”, this is the calculation:

Ballpark figures: Analyzing MLB baseball attendance | Domo (1)

You can see there are two things happening here.First, when I have the SUM FIXED by League, then it is summing across all values with the same league as the row I am on.That allows me to get that league total we need for the denominator of the index. Second, it is using FILTER ALLOW to tell Domo that filters on Year can impact the FIXED functions.There are options for FILTER ALLOW, FILTER DENY, and FILTER NONE.

Here’s one last example of how useful the FIXED with FILTER DENY can be.The bar charts below are defaulted to the New York Yankees (my boss’ favorite team).The first chart is not using FIXED, so when I filter for the Yankees, the Min, Max, and Median fields become meaningless since they get filtered to be the same as the selected team.The second chart uses FIXED and DENY on team name so that the Min, Max, and Median remain as references to the main average, which is for the Yankees.

One of the things I love—and also at times find maddening—about exploring new data is that there is always more to explore. As I worked on this post, I realized that it would be quite interesting to bring in teams’ win/loss records as well as information on stadium capacity. But then I thought: Let’s maybe save that for a future post.

Tags: baseball, box plot, FIXED, Jupyter

Ballpark figures: Analyzing MLB baseball attendance | Domo (2024)
Top Articles
How the Vlog Squad's Scotty Sire went from being a 'super shy kid' to finding millions of fans as a YouTuber and musician
Chase Bank Near Me? Find Branches And ATMs Close By
Parke County Chatter
What to Serve with Lasagna (80+ side dishes and wine pairings)
Nation Hearing Near Me
Does Publix Have Sephora Gift Cards
Ktbs Payroll Login
Signs Of a Troubled TIPM
zopiclon | Apotheek.nl
Skylar Vox Bra Size
Washington, D.C. - Capital, Founding, Monumental
Dutchess Cleaners Boardman Ohio
Gmail Psu
Aspen Mobile Login Help
Energy Healing Conference Utah
Vigoro Mulch Safe For Dogs
Ein Blutbad wie kein anderes: Evil Dead Rise ist der Horrorfilm des Jahres
Beverage Lyons Funeral Home Obituaries
Tu Pulga Online Utah
Violent Night Showtimes Near Century 14 Vallejo
About My Father Showtimes Near Copper Creek 9
Craigslist Illinois Springfield
Sam's Club Gas Price Hilliard
Delectable Birthday Dyes
Marilyn Seipt Obituary
Stockton (California) – Travel guide at Wikivoyage
Evil Dead Rise Ending Explained
Umn Biology
Things to do in Pearl City: Honolulu, HI Travel Guide by 10Best
Bj's Tires Near Me
49S Results Coral
Fairwinds Shred Fest 2023
Grays Anatomy Wiki
15 Downer Way, Crosswicks, NJ 08515 - MLS NJBL2072416 - Coldwell Banker
Makemkv Key April 2023
Justin Mckenzie Phillip Bryant
Orangetheory Northville Michigan
Asian Grocery Williamsburg Va
2008 Chevrolet Corvette for sale - Houston, TX - craigslist
Frank 26 Forum
Cal Poly 2027 College Confidential
Check From Po Box 1111 Charlotte Nc 28201
Arigreyfr
War Room Pandemic Rumble
What is 'Breaking Bad' star Aaron Paul's Net Worth?
The Average Amount of Calories in a Poke Bowl | Grubby's Poke
Sinai Sdn 2023
Argus Leader Obits Today
Smoke From Street Outlaws Net Worth
Kobe Express Bayside Lakes Photos
Karen Kripas Obituary
Famous Dave's BBQ Catering, BBQ Catering Packages, Handcrafted Catering, Famous Dave's | Famous Dave's BBQ Restaurant
Latest Posts
Article information

Author: Eusebia Nader

Last Updated:

Views: 5570

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.