Closed drscotthawley closed 4 years ago
Fixed... Apparently there's been a change in Pandas, at least for version 0.25.0 (the requirements.txt file for fma doesn't specify a version for pandas).
So the fix is to modify utils.py so that it includes
from pandas.api.types import CategoricalDtype
and the offending line about categories that used to read as
'category', categories=SUBSETS, ordered=True)
now reads as
CategoricalDtype(categories=SUBSETS, ordered=True))
. :-)
This error also appears in the creation notebook
Thanks for reporting! This behavior was indeed removed in pandas 0.25:
Removed the previously deprecated
ordered
andcategories
keyword arguments inastype
(GH17742)
I used pandas==0.21.0
when developing this code. I will add package versions to the requirements.txt
.
Hi, I tried to use the new code but the error persist in the next line. Thanks for your work.
TypeError Traceback (most recent call last)
<ipython-input-31-4224f39de5bf> in <module>()
1 AUDIO_DIR = os.environ.get('fma_small')
----> 2 tracks = utils.load('fma_metadata/tracks.csv')
/content/utils.py in load(filepath)
212 tracks[column] = tracks[column].astype('category')
213
--> 214 return tracks
215
216
TypeError: astype() got an unexpected keyword argument 'categories'
What does:
import pandas
print(pandas.__version__)
prints?
Thanks, I didn't realized that my pandas version was downgraded.
I tried to use the new code but the error persist in the next line.
The line number of the error (--> 214 return tracks
) seems to indicate you're not using the latest version. The latest has a try-catch block for this case:
212 try:
213 tracks['set', 'subset'] = tracks['set', 'subset'].astype(
214 'category', categories=SUBSETS, ordered=True)
215 except ValueError:
216 # the categories and ordered arguments were removed in pandas 0.25
217 tracks['set', 'subset'] = tracks['set', 'subset'].astype(
218 pd.CategoricalDtype(categories=SUBSETS, ordered=True))
So both old (pandas<0.25
) and new (pandas>=0.25
) pandas should work.
Could you try a fresh git clone
?
Hello, I know I'm a little late, but I would like to add that I am still getting the error despite the try-catch block.
Edit: I fixed it by removing the except ValueError: and just changing it to except:
Thanks for reporting @albert239825. Which exception did you get? If TypeError
, could you try #47? Which version of pandas (import pandas; print(pandas.__version__)
) are you using?
@mdeff I didn't get a type error. My pandas version is 1.2.2 and the error I get is "astype() got an unexpected keyword argument 'categories'".
Edit: Also, I undid a commit with the fix and now it's broken again...
Edit: Nevermind, changing
except ValueError:
to except:
fixed the issue as before
the error I get is "astype() got an unexpected keyword argument 'categories'"
And that's a TypeError
. 😉
Hence I'll merge #47.
@mdeff Thanks! So sorry for my lack of knowledge.
No problem. 😉 Thank you for following-up on the issue.
Hi, I've referred to the Usage section in the README as well as #9 and #10. I've checked out rc1 because it's appropriate for the version of fma_metadata.zip and fma_small.zip that I checked out, and also I've set my environment variables.
Nevertheless, running the line
in either the usage.ipynb file or my own very simple Python script will produce a ValueError about categories:
I haven't seen this error reported in any of the other issues. Can anyone help, e.g. @mdeff ? Thanks!