The full set of runners for all races during 2010.

This data set has 800k runners. The NYT had a good article - https://www.nytimes.com/2014/04/23/upshot/what-good-marathons-and-bad-investments-have-in-common.html?rref=upshot&_r=1.
marathon
Author

DS 150

Published

January 25, 2024

Data details

There are 821,303 rows and 20 columns. The data source1 is used to create our data that is stored in our pins table. You can access this pin from a connection to posit.byui.edu using hathawayj/marathon_2010.

This data is available to all.

Variable description

  • age The age of the runner
  • gender The gender of the runner (M/F)
  • chiptime The time in minutes for the runner
  • year The year of the marathon
  • marathon The name of the marathon
  • country The country where the marathon was held
  • finishers The number of finishers at the marathon

Variable summary

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
age 356927 0.57 39.40 10.92 6.00 31.00 39.00 47.00 91.00 ▁▇▆▁▁
split_half 456187 0.44 127.48 26.67 59.25 109.77 123.12 140.60 681.93 ▇▁▁▁▁
clocktime 375659 0.54 273.81 60.33 0.00 231.45 264.72 306.33 896.07 ▁▇▁▁▁
chiptime 0 1.00 267.78 58.01 122.27 228.02 259.07 297.23 874.23 ▇▅▁▁▁
year 0 1.00 2010.00 0.00 2010.00 2010.00 2010.00 2010.00 2010.00 ▁▁▇▁▁
split_10k 574912 0.30 61.01 12.83 27.33 52.52 59.08 67.07 196.75 ▇▆▁▁▁
split_30k 623570 0.24 194.56 44.96 82.90 163.15 186.90 217.93 511.85 ▅▇▁▁▁
split_40k 657161 0.20 273.52 63.82 115.88 227.02 263.68 309.80 599.22 ▂▇▃▁▁
finishers 0 1.00 13898.64 14144.96 2.00 2208.00 7880.00 22449.00 45109.00 ▇▂▂▁▂
meantime 0 1.00 267.76 28.07 168.56 250.25 266.10 276.10 443.81 ▁▇▂▁▁
female 141761 0.83 0.35 0.48 0.00 0.00 0.00 1.00 1.00 ▇▁▁▁▅
us 0 1.00 0.62 0.49 0.00 0.00 1.00 1.00 1.00 ▅▁▁▁▇
canada 0 1.00 0.03 0.18 0.00 0.00 0.00 0.00 1.00 ▇▁▁▁▁
europe 0 1.00 0.31 0.46 0.00 0.00 0.00 1.00 1.00 ▇▁▁▁▃
other 0 1.00 0.04 0.20 0.00 0.00 0.00 0.00 1.00 ▇▁▁▁▁
age_gender 0 1.00 0.47 0.50 0.00 0.00 0.00 1.00 1.00 ▇▁▁▁▇

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
gender 141761 0.83 1 1 0 2 0
marathon 0 1.00 7 62 0 641 0
country 0 1.00 2 14 0 33 0
marathon2 0 1.00 12 67 0 641 0
Explore generating code using R
pacman::p_load(pins, tidyverse, downloader, fs, glue, rvest, googledrive, connectapi)


# Data is from master_marathon. 
sdrive <- shared_drive_find("byuids_data") # This will ask for authentication.
google_file <- drive_ls(sdrive)  |>
  filter(stringr::str_detect(name, "master_marathon"))
tempf <- tempfile()
drive_download(google_file, tempf)
dat <- read_csv(tempf)


# Wrangle (filter to 2010)
marathon_2010 <- dat %>%
  filter(year == 2010)



board <- board_connect()
pin_write(board, marathon_2010, type = "parquet")

pin_name <- "marathon_2010"
meta <- pin_meta(board, paste0("hathawayj/", pin_name))
client <- connect()
my_app <- content_item(client, meta$local$content_id)
set_vanity_url(my_app, paste0("data/", pin_name))

Access data

This data is available to all.

Direct Download: marathon_2010.parquet

R and Python Download:

URL Connections:

For public data, any user can connect and read the data using pins::board_connect_url() in R.

library(pins)
url_data <- "https://posit.byui.edu/data/marathon_2010/"
board_url <- board_connect_url(c("dat" = url_data))
dat <- pin_read(board_url, "dat")

Use this custom function in Python to have the data in a Pandas DataFrame.

import pandas as pd
import requests
from io import BytesIO

def read_url_pin(name):
  url = "https://posit.byui.edu/data/" + name + "/" + name + ".parquet"
  response = requests.get(url)
  if response.status_code == 200:
    parquet_content = BytesIO(response.content)
    pandas_dataframe = pd.read_parquet(parquet_content)
    return pandas_dataframe
  else:
    print(f"Failed to retrieve data. Status code: {response.status_code}")
    return None

# Example usage:
pandas_df = read_url_pin("marathon_2010")

Authenticated Connection:

Our connect server is https://posit.byui.edu which you assign to your CONNECT_SERVER environment variable. You must create an API key and store it in your environment under CONNECT_API_KEY.

Read more about environment variables and the pins package to understand how these environment variables are stored and accessed in R and Python with pins.

library(pins)
board <- board_connect(auth = "auto")
dat <- pin_read(board, "hathawayj/marathon_2010")
import os
from pins import board_rsconnect
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv('CONNECT_API_KEY')
SERVER = os.getenv('CONNECT_SERVER')

board = board_rsconnect(server_url=SERVER, api_key=API_KEY)
dat = board.pin_read("hathawayj/marathon_2010")