Skip to main content

A python package for scraping kenpom.com NCAA basketball data.

Project description

kenpompy - Basketball for Nerds

Documentation Status codecov

This python package serves as a convenient web scraper for kenpom.com, which provides tons of great NCAA basketball statistics and metrics. It requires a subscription to Ken Pomeroy's site for use, otherwise only the home page will be accessible. It's a small fee for a year of access, and totally worth it in my opinion.

Objective

Ultimately, this package is to allow both hobbyist and reknown sports analysts alike to get data from kenpom in a format more suitable for visualization, transformation, and additional analysis. It's meant to be simple, easy to use, and to yield information in a way that is immediately usable.

Responsible Use

As with many web scrapers, the responsibility to use this package in a reasonable manner falls upon the user. Don't be a jerk and constantly scrape the site a thousand times a minute or you run the risk of potentially getting barred from it, which you'd likely deserve. I am in no way responsible for how you use (or abuse) this package. Be sensible.

But I Use R

Yeah, yeah, but have you heard of reticulate? It's an R interface to python that also supports passing objects (like dataframes!) between them.


Installation

kenpompy is easily installed via pip:

pip install kenpompy

What It Can (and Can't) Do

This a work in progress - it can currently scrape all of the summary, FanMatch, and miscellaneous tables, pretty much all of those under the Stats and Miscellany headings. Team and Player classes are planned, but they're more complicated and will take some time.

Usage

kenpompy is simple to use. Generally, tables on each page are scraped into pandas dataframes with simple parameters to select different seasons or tables. As many tables have headers that don't parse well, some are manually altered to a small degree to make the resulting dataframe easier to interpret and manipulate.

First, you must login:

from kenpompy.utils import login

# Returns an authenticated browser that can then be used to scrape pages that require authorization.
browser = login(your_email, your_password)

Then you can request specific pages that will be parsed into convenient dataframes:

import kenpompy.summary as kp

# Returns a pandas dataframe containing the efficiency and tempo stats for the current season (https://kenpom.com/summary.php).
eff_stats = kp.get_efficiency(browser)

Contributing

You can contribute by creating issues to highlight bugs and make suggestions for additional features. Pull requests are also very welcome.

License

kenpompy is released on the GNU GPL v3.0 license. You are free to use, modify, or redistribute it in almost any way, provided you state changes to the code, disclose the source, and use the same license. It is released with zero warranty for any purpose and I retain no liability for its use. Read the full license for additional details.

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

kenpompy-0.3.2.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

kenpompy-0.3.2-py3-none-any.whl (26.0 kB view details)

Uploaded Python 3

File details

Details for the file kenpompy-0.3.2.tar.gz.

File metadata

  • Download URL: kenpompy-0.3.2.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kenpompy-0.3.2.tar.gz
Algorithm Hash digest
SHA256 a4937e0b2a0b773c8a17e6241851d6c35ea3bdb1050faa9df7800ef1d9b2eb26
MD5 66de2547b3decdb1db443ffe3f1fae36
BLAKE2b-256 2864c97538b111499b33b685af2293e7bd18d6b7acdd622220a9826b799eef61

See more details on using hashes here.

File details

Details for the file kenpompy-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: kenpompy-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 26.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.13

File hashes

Hashes for kenpompy-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b37b9f0029aef6e1e966551228ac9453bebc284fe8e43af6406c8fb100660c50
MD5 e0c1bbbce57401e6c4143f4338409d69
BLAKE2b-256 32cfdbb25a66cb4299007541e21e6e84499bd2fa3cefa0f4e16829d38bd9f2f9

See more details on using hashes here.

Supported by

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