pyvolleydata.helpers

Functions

get_data(league, seasons, data_type)

Loads data for a specified league and season(s) from the volleydata repository.

validate_seasons(seasons, league_start_year)

Checks whether all the provided seasons are valid years and raises an error if not.

Module Contents

pyvolleydata.helpers.get_data(league, seasons, data_type)[source]

Loads data for a specified league and season(s) from the volleydata repository.

Parameters:
  • league (str) – A string specifying which of ‘mlv’, ‘pvf’, or ‘au’ to load data for.

  • data_type (str) – The type of data to fetch (e.g., ‘pbp’, ‘events_log’)

  • seasons (int, list of int, or None, optional) – Season(s) to load. By default, None loads all available seasons. - int : Single season year (e.g., 2025) - list of int : Multiple seasons (e.g., [2024, 2025]) - None : Load all available seasons

Returns:

A DataFrame containing the merged or filtered data with an additional ‘league’ column.

Return type:

pd.DataFrame

Examples

>>> fetch_data(league='mlv', data_type='pbp', seasons=2024)
>>> fetch_data(league='au', data_type='rosters', seasons=[2022, 2023])
>>> fetch_data(league='lovb', data_type='events_log')
pyvolleydata.helpers.validate_seasons(seasons, league_start_year)[source]

Checks whether all the provided seasons are valid years and raises an error if not.

Parameters:
  • seasons (list of int) – A list of years representing seasons to validate.

  • league_start_year (int) – The starting year to determine if the seasons are within range.

Return type:

None

Examples

>>> validate_seasons([2024, 2025], 2024)
>>> validate_seasons(['2020'], 2024)  # Raises TypeError
>>> validate_seasons([2022, 2023, 2030], 2024)  # Raises ValueError