python电影数据分析影评
时间: 2023-12-26 11:28:46 浏览: 37
以下是两种Python电影数据分析影评的例子:
1. 使用饼图展示性别比例:
```python
from pyecharts.charts import Pie
from pyecharts import options as opts
from pyecharts.globals import ThemeType
from collections import Counter
rates = []
for s in df.iloc[:, 8]:
if s != 1 and s != 2:
s = 3
rates.append(s)
gx = ["男", "女", "未知"]
gy = [rates.count(1), rates.count(2), rates.count(3)]
(Pie(init_opts=opts.InitOpts(theme=ThemeType.CHALK, width="700px", height="400px"))
.add("", list(zip(gx, gy)))
.set_global_opts(title_opts=opts.TitleOpts(title="性别比例", subtitle="数据来源:猫眼电影", pos_left="left"))
.set_series_opts(label_opts=opts.LabelOpts(formatter="{b}:{d}%", font_size=12))
).render_notebook()
```
2. 使用柱状图展示评论数量前15名的城市:
```python
from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.globals import ThemeType
from collections import Counter
data_top15 = Counter(cities).most_common(15)
gx2 = []
gy2 = []
for c in data_top15:
gx2.append(c[0])
gy2.append(c[1])
(Bar(init_opts=opts.InitOpts(theme=ThemeType.CHALK, width="700px", height="400px"))
.add_xaxis(gx2)
.add_yaxis("", gy2)
.set_global_opts(title_opts=opts.TitleOpts(title="城市来源 TOP15", subtitle="数据来源:猫眼电影", pos_left="center"))
).render_notebook()
```