j-andrews7/kenpompy

Error with Dataframe column mapping for get_playerstats()

cjt243 opened this issue · 6 comments

For 2P, 3P and FT metrics, the column mapping is 7 elements instead of 9.

image

And missing (2P for example):
image

So the 2P% is fitting, but the column mapping isn't accounting for attempts and makes.

I added an additional elif to the get_playerstats() function that essentially cleans up the dataframe properly (albeit a bit hacky):
ps_df.columns = ['Rank', 'Player', 'Team', metric.replace('%','M'), metric.replace('%','A'), metric, 'Ht', 'Wt', 'Yr']

You should be able to reproduce this:
df = kp.get_playerstats(browser,season=2020,metric='2P')

I get this Traceback (last error):
ValueError: Length mismatch: Expected axis has 9 elements, new values have 7 elements

This is indeed an oversight for 2P%, 3P%, and FT% metrics. I will push a fix soon.

This is fixed in a new release, v0.2.1. Thanks for reporting.

No problem, glad to help! Love the package btw