statsbomb / statsbombpy

Easily stream StatsBomb data into Python
566 stars 78 forks source link

Error on dataframe construction (API response) #4

Closed Torvaney closed 3 years ago

Torvaney commented 4 years ago

Running the example code from the README throws an error when the API response is coerced into a dataframe.

For example:

from statsbombpy import sb                                              

sb.competitions()                                                       

Gives the following error:

ValueError                                Traceback (most recent call last)
<ipython-input-3-dd8d79df577e> in <module>
----> 1 sb.competitions()

~/code/python/statsbombpy/statsbombpy/sb.py in competitions(fmt, creds)
     19         if isinstance(competitions, dict):
     20             competitions = competitions.values()
---> 21         competitions = pd.DataFrame(competitions)
     22     return competitions
     23 

~/miniconda3/lib/python3.7/site-packages/pandas/core/frame.py in __init__(self, data, index, columns, dtype, copy)
    420                                          dtype=values.dtype, copy=False)
    421             else:
--> 422                 raise ValueError('DataFrame constructor not properly called!')
    423 
    424         NDFrame.__init__(self, mgr, fastpath=True)

ValueError: DataFrame constructor not properly called!

Data can be fetched in the non-dataframe format, without any issues:

sb.competitions(fmt=None)

From pip freeze I am using:

pandas==0.23.4
-e git+https://github.com/statsbomb/statsbombpy@b11440f701f2bad9fd26456fa8d90929d716a9a3#egg=statsbombpy
joshm91 commented 4 years ago

Your pandas version is nearly 2 years out of date. The readme example works as expected for me with version 1.1.0

Torvaney commented 4 years ago

Good catch, thanks! I thought I'd created a frsh venv for this, but the miniconda3 in the traceback path seems to be telling a different story?

I guess the fix would be to add a minimum pandas version in setup.py, then

joshm91 commented 4 years ago

Yeah, that would work. It looks like pandas released 1.0.0 just a few days after the last commit to this repo. I can't seem to get the test_competition_events test to pass on any version at the moment so not entirely sure what the minimum required version would be.