I have the following dataset:
import pandas as pd
import numpy as np
%matplotlib inline
df = pd.DataFrame({'movie' : ['A', 'B','C','D'],
'genres': ['Science Fiction|Romance|Family', 'Action|Romance',
'Family|Drama','Mystery|Science Fiction|Drama']},
index=range(4))
df
My attempt
# Parse unique genre from all the movies
gen = []
for g in df['genres']:
gg = g.split('|')
gen = gen + gg
gen = list(set(gen))
print(gen)
df['genres'].value_counts().plot(kind='pie')
But I would like to pie chart for each separate genres.
How we get the genres for number count of movies for each unique genres?