From 23a6299d5ac9190cc32dcae076c093fa6201cc5c Mon Sep 17 00:00:00 2001 From: pn2yfabhg <1249144594@qq.com> Date: Sat, 8 Jun 2024 17:07:36 +0800 Subject: [PATCH] ADD file via upload --- app.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..755003a --- /dev/null +++ b/app.py @@ -0,0 +1,48 @@ +import pandas as pd +import matplotlib.pyplot as plt +from pyecharts.charts import Bar,Scatter,Pie +from pyecharts import options as opts +from pyecharts.charts import Scatter3D + +from pyecharts.charts import WordCloud +from pyecharts.globals import SymbolType +from pyecharts.charts import Timeline + +df =pd.read_csv('flaskProject/data/export.csv') +def tubiao_country_bar(): + country_counts = df['country'].value_counts().head(10) + bar=( + Bar() + .add_xaxis(country_counts.index.tolist()) + .add_yaxis("电影数量",country_counts.tolist()) + .set_global_opts(title_opts=opts.TitleOpts("按国家分组统计电影数量 Top 10")) + ) + bar.render('country_movie_count.html') + +def tubiao_top10_reviews(): + top10_reviews=df.nlargest(10,'num_reviews') + bar=( + Bar() + .add_xaxis(top10_reviews['title'].tolist()) + .add_yaxis("评价人数",top10_reviews['num_reviews'].tolist()) + .set_global_opts(title_opts=opts.TitleOpts(title="评价人数 Top 10")) + ) + bar.render('top10reviews.html') + + scatter=( + Scatter() + .add_xaxis(df['ranking'].tolist()) + .add_yaxis('电影评分',df['rating'].tolist()) + .set_global_opts( + title_opts=opts.TitleOpts(title="高分电影评分-排名散点分布图"), + xaxis_opts=opts.AxisOpts(type_='value',name="电影排名"), + yaxis_opts=opts.AxisOpts(type_='value', name="电影评分") + ) + ) + scatter.render("rating_ranting_scatter.html") + + + + +tubiao_country_bar() +tubiao_top10_reviews() \ No newline at end of file