Python Forum
Movie lens data analysis
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Movie lens data analysis
#1
Data set screenshot

how can i find the number of movies per genre using the item data
movies that have more than one genre
drop the movie where genre is unknown
Reply
#2
  • how can i find the number of movies per genre using the item data - Using .count() per movie dataframe column & you should be able to get number of movies per genre

  • movies that have more than one genre - Total the columns of all genere's per movie & if count>1 then it that movie has more than 1 genre

  • drop the movie where genre is unknown - select all movie's where df['unknown'] ==1


Reply
#3
hi satya,

thank you for your reply really appriciate, i dont have any programming background so struggling a bit on this

i have used

df=pd.DataFrame({'Genre':['unknown','Action','Adventure','Animation','Childrens','Comedy','Crime','Documentary','Drama','Fantasy','Film-Noir','Horror','Musical','Mystery','Romance','Sci-Fi','Thriller','War','Western']},
index=['movie title'])

df.set_index(["unknown","Action","Adventure","Animation","Childrens","Comedy","Crime","Documentary","Drama","Fantasy","Film-Noir","Horror","Musical","Mystery","Romance","Sci-Fi","Thriller","War","Western"]).count(level="movie title")

but its not working am doing any thing wrong

those columns of genre if they are as rows corresponding to movie name probably would have been easy one hot coding changed the rows to columns i dont know how to put that columns to rows again

Oh sorry .. my bad .. didnt know it was suppose to be done like that..

corrected

df=pd.DataFrame({'Genre': ['unknown','Action','Adventure','Animation','Childrens','Comedy','Crime','Documentary','Drama','Fantasy','Film-Noir','Horror','Musical','Mystery','Romance','Sci-Fi','Thriller','War','Western']},
                  index=['movie title'])

df.set_index(["unknown","Action","Adventure","Animation","Childrens","Comedy","Crime","Documentary","Drama","Fantasy","Film-Noir","Horror","Musical","Mystery","Romance","Sci-Fi","Thriller","War","Western"]).count(level="movie title")
Reply
#4
(Feb-19-2020, 02:36 PM)sekhar_desiraju Wrote: hi satya,

thank you for your reply really appriciate, i dont have any programming background so struggling a bit on this

i have used

df=pd.DataFrame({'Genre':['unknown','Action','Adventure','Animation','Childrens','Comedy','Crime','Documentary','Drama','Fantasy','Film-Noir','Horror','Musical','Mystery','Romance','Sci-Fi','Thriller','War','Western']},
index=['movie title'])

df.set_index(["unknown","Action","Adventure","Animation","Childrens","Comedy","Crime","Documentary","Drama","Fantasy","Film-Noir","Horror","Musical","Mystery","Romance","Sci-Fi","Thriller","War","Western"]).count(level="movie title")

but its not working am doing any thing wrong

those columns of genre if they are as rows corresponding to movie name probably would have been easy one hot coding changed the rows to columns i dont know how to put that columns to rows again

Oh sorry .. my bad .. didnt know it was suppose to be done like that..

corrected

df=pd.DataFrame({'Genre': ['unknown','Action','Adventure','Animation','Childrens','Comedy','Crime','Documentary','Drama','Fantasy','Film-Noir','Horror','Musical','Mystery','Romance','Sci-Fi','Thriller','War','Western']},
                  index=['movie title'])

df.set_index(["unknown","Action","Adventure","Animation","Childrens","Comedy","Crime","Documentary","Drama","Fantasy","Film-Noir","Horror","Musical","Mystery","Romance","Sci-Fi","Thriller","War","Western"]).count(level="movie title")

I tried to work with the lines of code to solve the same problem but it is not returning the right solution. Any reason why this is the case?
Reply
#5
Hi There,

Can you please share the code here as well for the question movies that have more than one Genre. My answer is coming zero. Not sure Sad

Looking forward to hear from you!

Thanks!
SHivam
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Data Analysis darkapostle 1 3,064 Sep-28-2018, 12:55 AM
Last Post: ichabod801
  Sentiment Analysis with NLTK Vader - Writing data in one row ulrich48155 1 4,113 May-15-2017, 06:36 AM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020