IMDB 5000 Movie Dataset 数据分析学习记录

import matplotlib.pyplot as plt
grouped = movies_df.groupby('country').size()
grouped_head_10=grouped.sort_values( ascending=False ).head(10)
print(grouped_head_10)#按照值排序
print(grouped.sort_index())#按照索引排序
grouped.plot(kind = 'bar')
plt.show()
grouped_head_10.plot(kind = 'bar')
plt.show()
[/code]

![这里写图片描述](https://img-
blog.csdn.net/20170820120103298?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbTBfMzc3NDQyOTM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
**高质量电影分布**
前10名高质量电影的国家和具体数量

```code
movie_max=movies_df['imdb_score'].sort_values(ascending=False).head(10)
print(pd.Index(movie_max ))
movie_max1=movies_df.sort_values(['imdb_score'],ascending=False).head(10)
#print(pd.Index(movie_max1 ))
print(movie_max1)
print(movie_max1[['movie_title','imdb_score']])
[/code]

**运行结果**

```code
movie_title imdb_score
1937 The Shawshank Redemption 9.3
3466 The Godfather 9.2
66 The Dark Knight 9.0
2837 The Godfather: Part II 9.0
4498 The Good, the Bad and the Ugly 8.9
339 The Lord of the Rings: The Return of the King 8.9
3355 Pulp Fiction 8.9
1874 Schindler's List 8.9
2051 Star Wars: Episode V - The Empire Strikes Back 8.8
683 Fight Club 8.8
[/code]

```code
movie_max_series=pd.Series(movie_max['imdb_score'].values,index = movie_max['movie_title'])
print(movie_max_series)
movie_max_series.plot(kind='bar')
plt.show()
[/code]

![这里写图片描述](https://img-
blog.csdn.net/20170820155116824?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbTBfMzc3NDQyOTM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)

**每年的电影数量**
以后的工作根据历史数据预测下一年的电影数量。

```code
grouped_year= movies_df.groupby('title_year').size()
print(grouped_year)
grouped_year.plot()
plt.show()
[/code]

![这里写图片描述](https://img-
blog.csdn.net/20170820165724377?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbTBfMzc3NDQyOTM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
后续内容继续更新


![在这里插入图片描述](https://img-blog.csdnimg.cn/20210608151750993.gif)

posted on 2021-06-28 21:58  BabyGo000  阅读(275)  评论(0)    收藏  举报