Skip to main content

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.

Metadata

Release files for kenpompy 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kenpompy 0.5.0
File Size Uploaded
kenpompy-0.5.0.tar.gz 34.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kenpompy 0.5.0
File Interpreter ABI Platform
kenpompy-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.0 kB

Release files / kenpompy-0.5.0.tar.gz

Download URL kenpompy-0.5.0.tar.gz
Size 34.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8f4429e415b418e84e20bb76e405b792251fae7e8f30dcb7682bc945d33f8cf3
BLAKE2b-256 checksum
How to use checksums
2c65febb960d2cfcfd265879e2cb62408d4e1cfdc9da7af0e596ce050a1b70c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release files / kenpompy-0.5.0-py3-none-any.whl

Download URL kenpompy-0.5.0-py3-none-any.whl
Size 30.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
915c61f19258cc1db231e4993cd744897e92ea9e8024fe23dc9fc058e7a4716b
BLAKE2b-256 checksum
How to use checksums
ef891101b226bfe73a44a343f97a3e31881a1f9a111739fa7ac3f0bc70aa8e3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.11

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page