🤵♂️ 个人主页:@艾派森的个人主页

✍🏻作者简介:Python学习者
🐋 希望大家多多支持,我们一起进步!😄
如果文章对你有帮助的话,
欢迎评论 💬点赞👍🏻 收藏 📂加关注+


目录

1.项目背景

2.数据集介绍

3.技术工具

4.导入数据

5.数据可视化

文末推荐与福利


 

1.项目背景

        随着全球化的深入发展,电影作为一种文化表达和艺术形式,逐渐超越了国界,成为世界各地观众共同欣赏的对象。2023年TOP100国外电影榜单的发布,正是这一发展趋势的体现。为了更好地理解这一现象,我们决定对这100部电影进行数据可视化分析,以期揭示其背后的文化、市场和艺术特征。

        近年来,电影产业的数字化和网络化带来了海量的数据资源,这为我们的研究提供了可能。通过数据挖掘和分析,我们可以了解哪些类型的电影更受欢迎,哪些地区或国家的电影在全球范围内有更大的影响力,以及观众的喜好和行为模式等。

        电影不仅仅是一种娱乐方式,它还是一个反映社会现象、传达价值观和塑造文化认同的重要工具。通过研究TOP100国外电影,我们可以深入了解不同文化背景下的故事、主题和表达方式,从而增进国际间的文化交流和理解。

        此外,电影市场的竞争也日益激烈。通过数据可视化,我们可以分析电影的票房、口碑和影响力之间的关系,为电影产业的决策者提供有价值的参考信息,以促进电影产业的健康和可持续发展。

        总之,2023年TOP100国外电影数据可视化研究旨在利用现代数据分析技术,深入挖掘电影数据的价值,理解电影作为一种全球性文化的现象,增进国际文化交流,并为电影产业的未来发展提供决策支持。

2.数据集介绍

        数据集来源与Kaggle,原始数据集为2023年国外最佳的前100部电影数据,共有如下变量:

列名

描述

name

电影的标题。

rating

给电影的评级。

votes

电影获得的票数。

runtime

电影的持续时间或运行时间。

genre

电影所属的流派。

description

电影的简要概述或描述。

3.技术工具

Python版本:3.9

代码编辑器:jupyter notebook

4.导入数据

导入第三方库和数据

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import warnings
warnings.filterwarnings('ignore')
sns.set_style('darkgrid')
plt.style.use('ggplot')

df = pd.read_csv('moviesdataset_2023.csv')
df.head()

查看数据大小

数据分析案例-2023年TOP100国外电影数据可视化_数据

查看数据基本信息

数据分析案例-2023年TOP100国外电影数据可视化_数据_02

# 数据类型转换
df['rating'] = pd.to_numeric(df['rating'], errors='coerce')
df['votes'] = pd.to_numeric(df['votes'].str.replace(',', ''), errors='coerce')
df['runtime'] = pd.to_numeric(df['runtime'].str.replace(' min', ''), errors='coerce')

查看描述性统计

数据分析案例-2023年TOP100国外电影数据可视化_数据分析_03

5.数据可视化

import matplotlib.pyplot as plt
import seaborn as sns
plt.figure(figsize=(10, 6))
sns.histplot(df['rating'].dropna(), bins=10, kde=True, color='skyblue')
plt.title('Distribution of Ratings')
plt.xlabel('Rating')
plt.ylabel('Frequency')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据_04

plt.figure(figsize=(10, 6))
sns.scatterplot(x='rating', y='votes', data=df, color='coral')
plt.title('Relationship between Rating and Votes')
plt.xlabel('Rating')
plt.ylabel('Votes')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据_05

genres_count = df['genre'].explode().value_counts()
plt.figure(figsize=(12, 8))
genres_count.plot(kind='bar', color='salmon')
plt.title('Movie Genres Count')
plt.xlabel('Genres')
plt.ylabel('Count')
plt.xticks(rotation=45, ha='right')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据可视化_06

plt.figure(figsize=(10, 6))
sns.histplot(df['runtime'].dropna(), bins=15, kde=True, color='lightgreen')
plt.title('Distribution of Runtime')
plt.xlabel('Runtime (minutes)')
plt.ylabel('Frequency')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据分析_07

plt.figure(figsize=(12, 8))
sns.pairplot(df[['rating', 'votes', 'runtime']])
plt.suptitle('Pair Plot for Numerical Columns', y=1.02)
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_信息可视化_08

plt.figure(figsize=(14, 8))
sns.countplot(y='genre', data=df, order=df['genre'].explode().value_counts().index, palette='viridis')
plt.title('Count of Movies in Each Genre')
plt.xlabel('Count')
plt.ylabel('Genres')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据分析_09

# 相关系数热力图
plt.figure(figsize=(10, 8))
correlation_matrix = df[['rating', 'votes', 'runtime']].corr()
sns.heatmap(correlation_matrix, annot=True, cmap='coolwarm', linewidths=.5)
plt.title('Correlation Heatmap')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据分析_10

plt.figure(figsize=(14, 8))
sns.boxplot(x='runtime', y='genre', data=df, palette='Set2')
plt.title('Box Plot of Runtime Across Genres')
plt.xlabel('Runtime (minutes)')
plt.ylabel('Genres')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_数据分析_11

# 电影描述词云图
from wordcloud import WordCloud
# 将所有描述组合成一个字符串
all_descriptions = ' '.join(df['description'])
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(all_descriptions)
plt.figure(figsize=(12, 6))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.title('Word Cloud for Movie Descriptions')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_python_12

average_rating_by_genre = df.groupby('genre')['rating'].mean().sort_values(ascending=False)
plt.figure(figsize=(14, 8))
sns.barplot(x=average_rating_by_genre.values, y=average_rating_by_genre.index, palette='coolwarm')
plt.title('Average Rating Across Genres')
plt.xlabel('Average Rating')
plt.ylabel('Genres')
plt.show()

数据分析案例-2023年TOP100国外电影数据可视化_信息可视化_13