数据可视化分析票房数据报告_票房收入分析和可视化

数据可视化分析票房数据报告

Welcome back to my 100 Days of Data Science Challenge Journey. On day 4 and 5, I work on TMDB Box Office Prediction Dataset available on Kaggle.

欢迎回到我的100天数据科学挑战之旅。 在第4天和第5天,我将研究Kaggle上提供的TMDB票房预测数据集。

I’ll start by importing some useful libraries that we need in this task.

我将从导入此任务中需要的一些有用的库开始。

import pandas as pd# for visualizations
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
plt.style.use('dark_background')

数据加载与探索 (Data Loading and Exploration)

Once you downloaded data from the Kaggle, you will have 3 files. As this is a prediction competition, you have train, test, and sample_submission file. For this project, my motive is only to perform data analysis and visuals. I am going to ignore test.csv and sample_submission.csv files.

从Kaggle下载数据后,您将拥有3个文件。 由于这是一场预测比赛,因此您具有训练,测试和sample_submission文件。 对于这个项目,我的动机只是执行数据分析和视觉效果。 我将忽略test.csv和sample_submission.csv文件。

Let’s load train.csv in data frame using pandas.

让我们使用熊猫在数据框中加载train.csv。

%time train = pd.read_csv('./data/tmdb-box-office-prediction/train.csv')# output
CPU times: user 258 ms, sys: 132 ms, total: 389 ms
Wall time: 403 ms

关于数据集: (About the dataset:)

id: Integer unique id of each moviebelongs_to_collection: Contains the TMDB Id, Name, Movie Poster, and Backdrop URL of a movie in JSON format.budget: Budget of a movie in dollars. Some row contains 0 values, which mean unknown.genres: Contains all the Genres Name & TMDB Id in JSON Format.homepage: Contains the official URL of a movie.imdb_id: IMDB id of a movie (string).original_language: Two-digit code of the original language, in which the movie was made.original_title: The original title of a movie in original_language.overview: Brief description of the movie.popularity: Popularity of the movie.poster_path: Poster path of a movie. You can see full poster image by adding URL after this link → https://image.tmdb.org/t/p/original/production_companies: All production company name and TMDB id in JSON format of a movie.production_countries: Two-digit code and the full name of the production company in JSON format.release_date: The release date of a movie in mm/dd/yy format.runtime: Total runtime of a movie in minutes (Integer).spoken_languages: Two-digit code and the full name of the spoken language.status: Is the movie released or rumored?tagline: Tagline of a movietitle: English title of a movieKeywords: TMDB Id and name of all the keywords in JSON format.cast: All cast TMDB id, name, character name, gender (1 = Female, 2 = Male) in JSON formatcrew: Name, TMDB id, profile path of various kind of crew members job like Director, Writer, Art, Sound, etc.revenue: Total revenue earned by a movie in dollars.

Let’s have a look at the sample data.

让我们看一下样本数据。

train.head()

As we can see that some features have dictionaries, hence I am dropping all such columns for now.

如我们所见,某些功能具有字典,因此我暂时删除所有此类列。

train = train.drop(['belongs_to_collection', 'genres', 'crew',
'cast', 'Keywords', 'spoken_languages', 'production_companies', 'production_countries', 'tagline','overview','homepage'], axis=1)

Now it time to have a look at statistics of the data.

现在该看一下数据统计了。

print("Shape of data is ")
train.shape# OutputShape of data is
(3000, 12)

Dataframe information.

数据框信息。

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是一些Python库和步骤,可以用于电影票房数据分析可视化。 ### 1. 数据获取与处理 可以通过爬取电影票房数据的网站(如猫眼电影、豆瓣电影等)来获取数据。也可以从公开的数据集中获取数据(如Kaggle上的电影数据集)。 获取到数据后,需要进行数据清洗和处理,如去除重复数据、缺失值处理等。可以使用Pandas库进行数据处理和清洗工作。 ```python import pandas as pd # 读取CSV数据文件 data = pd.read_csv('movie_data.csv') # 去除重复数据 data.drop_duplicates(inplace=True) # 处理缺失值 data.fillna(0, inplace=True) ``` ### 2. 数据分析 进行数据分析前,需要先了解数据的基本情况和特征。可以使用Pandas库提供的一些基本统计函数,如describe()、mean()、median()等来获取数据的基本信息。 ```python # 查看数据基本信息 print(data.info()) # 查看数据描述性统计信息 print(data.describe()) # 查看数据前5行 print(data.head()) ``` 在对数据进行分析时,可以根据问题需求,选择合适的统计方法和可视化方式。以下是一些常用的统计方法和可视化工具: - 统计方法:计数、求和、平均、中位数、方差、协方差、相关系数等。 - 可视化工具:Matplotlib、Seaborn、Plotly等。 ### 3. 数据可视化 使用Matplotlib库进行数据可视化,可以制作直方图、散点图、折线图、饼图等。 ```python import matplotlib.pyplot as plt # 绘制票房数据直方图 plt.hist(data['box_office'], bins=20) plt.title('Box Office') plt.xlabel('Box Office (Million)') plt.ylabel('Frequency') plt.show() # 绘制票房与评分散点图 plt.scatter(data['rating'], data['box_office']) plt.title('Box Office vs Rating') plt.xlabel('Rating') plt.ylabel('Box Office (Million)') plt.show() # 绘制不同年份电影数量折线图 year_count = data.groupby('year')['title'].count() plt.plot(year_count.index, year_count.values) plt.title('Movie Count by Year') plt.xlabel('Year') plt.ylabel('Movie Count') plt.show() ``` 使用Seaborn库进行数据可视化,可以制作热力图、箱线图、条形图、密度图等。 ```python import seaborn as sns # 绘制票房与评分箱线图 sns.boxplot(x='rating', y='box_office', data=data) plt.title('Box Office vs Rating') plt.xlabel('Rating') plt.ylabel('Box Office (Million)') plt.show() # 绘制不同地区电影数量条形图 region_count = data['region'].value_counts() sns.barplot(x=region_count.index, y=region_count.values) plt.title('Movie Count by Region') plt.xlabel('Region') plt.ylabel('Movie Count') plt.show() # 绘制票房密度图 sns.kdeplot(data['box_office']) plt.title('Box Office Density') plt.xlabel('Box Office (Million)') plt.show() ``` 使用Plotly库进行数据可视化,可以制作交互式图表,如散点图、热力图、地图等。 ```python import plotly.graph_objs as go import plotly.offline as pyo # 绘制票房与评分散点图(交互式) trace = go.Scatter(x=data['rating'], y=data['box_office'], mode='markers') layout = go.Layout(title='Box Office vs Rating', xaxis={'title': 'Rating'}, yaxis={'title': 'Box Office (Million)'}) fig = go.Figure(data=[trace], layout=layout) pyo.plot(fig) # 绘制不同地区电影数量地图(交互式) region_count = data['region'].value_counts() data_map = [go.Choropleth( locationmode='country names', locations=region_count.index, z=region_count.values)] layout_map = go.Layout(title='Movie Count by Region') fig_map = go.Figure(data=data_map, layout=layout_map) pyo.plot(fig_map) ``` 以上是一些基本的数据分析可视化方法,可以根据具体需要进行更加详细的分析可视化

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值