【发布时间】:2019-02-07 12:29:15
【问题描述】:
我有以下数据集:
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
我的尝试
# 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')
但我想为每个单独的流派制作饼图。
我们如何获得每种独特类型的电影数量的类型?
【问题讨论】:
标签: python pandas matplotlib plot imdb