我将导演的腐烂西红柿评分与以下内容分组:
director_counts = bigbadpanda.groupby(["Director"]).size().order(ascending = False)
print director_counts --->
Director
Woody Allen 44
Alfred Hitchcock 38
Clint Eastwood 32
Martin Scorsese 29
Steven Spielberg 29
Sidney Lumet 25
...
问题: 对于我有超过2部电影的导演进行过滤的最佳方式是什么?
按照每位导演的平均电影进行过滤会有效吗? bigbadpanda.groupby(["Director"]).size().mean()
)
答案 0 :(得分:1)
我根据您的信息创建的数据
Director,Movies
Woody Allen,44
Alfred Hitchcock,38
Clint Eastwood,32
Someone,2
Someone else,1
只需这样做:
df = pd.read_csv('data.txt')
print(df[df.Movies > 2])
输出:
Director Movies
0 Woody Allen 44
1 Alfred Hitchcock 38
2 Clint Eastwood 32