Coder Social home page Coder Social logo

Comments (13)

drscotthawley avatar drscotthawley commented on August 16, 2024 17

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))

. :-)

from fma.

andimarafioti avatar andimarafioti commented on August 16, 2024 1

What does:

import pandas
print(pandas.__version__)

prints?

from fma.

andimarafioti avatar andimarafioti commented on August 16, 2024

This error also appears in the creation notebook

from fma.

mdeff avatar mdeff commented on August 16, 2024

Thanks for reporting! This behavior was indeed removed in pandas 0.25:

Removed the previously deprecated ordered and categories keyword arguments in astype (GH17742)

I used pandas==0.21.0 when developing this code. I will add package versions to the requirements.txt.

from fma.

717101 avatar 717101 commented on August 16, 2024

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'

from fma.

717101 avatar 717101 commented on August 16, 2024

Thanks, I didn't realized that my pandas version was downgraded.

from fma.

mdeff avatar mdeff commented on August 16, 2024

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?

from fma.

albert239825 avatar albert239825 commented on August 16, 2024

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:

from fma.

mdeff avatar mdeff commented on August 16, 2024

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?

from fma.

albert239825 avatar albert239825 commented on August 16, 2024

@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

from fma.

mdeff avatar mdeff commented on August 16, 2024

the error I get is "astype() got an unexpected keyword argument 'categories'"

And that's a TypeError. 😉

20210318_232852

Hence I'll merge #47.

from fma.

albert239825 avatar albert239825 commented on August 16, 2024

@mdeff Thanks! So sorry for my lack of knowledge.

from fma.

mdeff avatar mdeff commented on August 16, 2024

No problem. 😉 Thank you for following-up on the issue.

from fma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.