利用pyecharts实现一个简陋的漏斗图
from pyecharts import options as opts
from pyecharts.charts import Funnel
# from pyecharts.faker import Faker
import pandas as pd
dt =pd.read_excel("C:/Users/ganyu/Desktop/test.xlsx",sheet_name=1)
数据:
将数据整理成二维列表
[
[key,value],
[key,value],
…
]
作图:
data = []
for d in dt.values:
data.append(list(d))
c = (Funnel()
.add("资产/w",
data,
label_opts=opts.LabelOpts(position="inside"),
sort_="ascending",)
.set_global_opts(title_opts=opts.TitleOpts(title="漏斗图"))
)
c.render_notebook()
效果: