cricinfo package

cricinfo.cricinfo module

class cricinfo.cricinfo.Cricinfo[source]

Bases: object

Loads cricket statistics from ESPN Cricinfo into pandas DataFrames.

Example:

from cricinfo import Cricinfo, Team, MatchFormat, StatType

df = Cricinfo.retrieve_stats(
    team=Team.Pakistan,
    match_format=MatchFormat.T20I,
    stat_type=StatType.BATTING,
)
static retrieve_stats(team: Team | None, match_format: MatchFormat, stat_type: StatType) DataFrame[source]

Retrieve statistics from ESPN Cricinfo.

Parameters:
  • team – Filter by team, or None for all teams.

  • match_format – The match format to filter by.

  • stat_type – The type of statistics to retrieve.

Returns:

A DataFrame containing the requested statistics.

Raises:
  • requests.HTTPError – If the HTTP request fails.

  • ValueError – If the response cannot be parsed.

cricinfo.stat_type module

class cricinfo.stat_type.StatType(*values)[source]

Bases: Enum

The type of statistics to retrieve.

Each type corresponds to a different statistics table on ESPN Cricinfo:

  • BATTING, BOWLING, FIELDING, ALLROUND: Career player statistics.

  • PARTNERSHIP: Partnership records for a team.

  • TEAM: Overall team records.

  • AGGREGATE: Aggregated team statistics across matches.

AGGREGATE = 'aggregate'
ALLROUND = 'allround'
BATTING = 'batting'
BOWLING = 'bowling'
FIELDING = 'fielding'
PARTNERSHIP = 'fow'
TEAM = 'team'

cricinfo.match_format module

class cricinfo.match_format.MatchFormat(*values)[source]

Bases: Enum

Filter statistics by match format.

International aggregates stats across Test, ODI, and T20I.

International = '11'
ODI = '2'
T20I = '3'
Test = '1'

cricinfo.team module

class cricinfo.team.Team(*values)[source]

Bases: Enum

Filter statistics by team.

Pass None to retrieve stats for all teams.

Afghanistan = '40'
Australia = '2'
Bangladesh = '25'
England = '1'
India = '6'
Ireland = '29'
NewZealand = '5'
Pakistan = '7'
SouthAfrica = '3'
SriLanka = '8'
WestIndies = '4'
Zimbabwe = '9'