Skip to main content

No project description provided

Project description

Cricguru

Overview

Cricguru is a data extraction module for extracting data from the Statsguru data query on Cricinfo. I was inspired to build a simple tool to extract dataframes from statsguru for analyzing cricket data and was finding it difficult to obtain overall figures from the website as they did not have an API for it. Cricinfo has a large variety of cricket data for all classes of cricket matches and also in-depth player data. However without an API it is impossible to extract any useful information from it. Hence this module has functions to easily get the cricket data we want without having to manually scrape the website. The data output is currently returned in the form of Pandas dataframes. You can find the full documentation here.

Team Data

Data by team can be obtained for the three main classes of cricket formats which are Test, One-day and T20. Excluding the class argument would return the overall data. In order to filter by teams and opposition you must provide one of the following ids to the team and opposition arguments respectively for some popular teams.

{"all teams": "", "Afghanistan": "40", "Australia": "2", "Bangladesh": "25", "England": "1", "ICC World XI": "140", "India": "6", "Ireland": "29", "New Zealand": "5", "Pakistan": "7", "South Africa": "3", "Sri Lanka": "8", "West Indies": "4", "Zimbabwe": "9"}

Player Data

Data by player can be obtained for the same classes mentioned above. The player class however requires a player id which can be obtained from Cricinfo by selecting a team followed by a player from that team. For example Angelo Mathew's id is 49764 which can be found appended to the url of the player's stats page on Cricinfo.

Built With

This project primarily uses Python 3.8 in combination with Pandas. Pandas is used to get the tables directly from the Statsguru query pages and convert them to dataframes. Urllib is used to format the url and append the query parameters. Poetry is used for packaging and publishing.

Getting Started

You can install the package using the following command.

pip install cricguru

Usage

You can get overall figures for all teams with the following. You must pass in the query parameters in a dictionary as shown. The "template" key with a "results" value is required along with the "class" variable which specifies which format of cricket you require data from. The classes for each format are as follows.
1 - Test
2 - ODI
3 - T20
11 - All
10 - Women's T20i
8 - Women's Test
9 - Women's ODI
20 - Youth Test
21 - Youth ODI
22 - Youth T20

from cricguru import team

team = team.Team()
query_params = {"template": "results", "class": "2"}
cric_data = team.overall(query_params)

#Returns a pandas dataframe
cric_data.head()

For player data you have to provide the player id to initialize the player object and then call the function for the type of data you require. You have to specify what type of player data you need such as allround, batting or bowling.

from cricguru import player

player = player.Player(49764)
query_params = {
    'class' : '1',
    'type' : 'allround'
}

cric_data = player.career_summary(query_params)
print(cric_data.head())

Contributing

This is an amateur project at best and I am still a complete beginner to Python and would greatly welcome any suggestions, advice, constructive criticism, best practices or contributions to the project. Simply open a pull request or issue and I will check it out.

Contact

You can also contact me at pavithranthilakanathan@gmail.com or on twitter - @pavin_v1

License

Distributed under the MIT license. See `LICENSE.md' for more information.

Acknowledgements

Todo

  • 100% code coverage
  • Additional data formats

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cricguru-2.0.1.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cricguru-2.0.1-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file cricguru-2.0.1.tar.gz.

File metadata

  • Download URL: cricguru-2.0.1.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Windows/10

File hashes

Hashes for cricguru-2.0.1.tar.gz
Algorithm Hash digest
SHA256 7d36e1934957587018499e4432fce25cbdb8f385f85bc02749d30f694f7e7b5d
MD5 7fc47532d4bfb8923789a8e01eb1a48b
BLAKE2b-256 64e9a7bc814d5e2135e3dd096670184bd15254e2c8717e001b94d5d22efc518c

See more details on using hashes here.

File details

Details for the file cricguru-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: cricguru-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.13 Windows/10

File hashes

Hashes for cricguru-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 31a0dcb9a68d1b2cc29c9008babaa022dbfa5a1320caf254c7a041a5ee42a0cc
MD5 e4c668bd586bb2647221e718f32e73fb
BLAKE2b-256 4a9ced63ad2daa76198bbcc72bf7eaa9d5d1d04dbec6684f4fcd883745309cfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page