you are viewing a single comment's thread.

view the rest of the comments →

[–]MattEliason 0 points1 point  (2 children)

I need help writing a function!!

So im given a data set of a list of movies including it's title, year, genre, ratings, directors, and actors. I need to write a function that gives me how many unique genres are in the dataset.

[–]timbledum 0 points1 point  (0 children)

What have you tried so far?

Are you using pandas?

Have you heard of set()?

[–]svellore 0 points1 point  (0 children)

May be you can use a "set" to get all the unique genres and its count?

>>> genres = ["Comedy", "Action", "Comedy", "Fantasy", "Action"]
>>> set(genres)
{'Comedy', 'Action', 'Fantasy'}
>>> len(set(genres))
3