You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.6 KiB
48 lines
1.6 KiB
6 months ago
|
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()
|