data_date = data.groupby('date')['clk'].agg({
'展示量':'count',
'点击量':sum,
'点击率':np.mean
})
from pyecharts import options as opts
from pyecharts.charts import Bar, Line
from pyecharts.faker import Faker
name = data_date.index.tolist()
v1 = data_date.展示量.tolist()
v2 = data_date.点击量.tolist()
v3 = ((data_date.点击率.values)*100).tolist()
v3 = [round(i,2) for i in v3]
bar = (
Bar(init_opts=opts.InitOpts(width="680px", height="420px"))
.add_xaxis(name)
.add_yaxis("展示量", v1)
.add_yaxis("点击量", v2)
.extend_axis(
yaxis=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} %"), interval=1)
)
.set_series_opts(label_opts=opts.LabelOpts(is_show=True))
.set_global_opts(
title_opts=opts.TitleOpts(title="2017/05/05至2017/05/13的广告点击情况",pos_left="18%"),
yaxis_opts=opts.AxisOpts(axislabel_opts=opts.LabelOpts(formatter="{value} "), max_=350000),
legend_opts=opts.LegendOpts(pos_top="10%", pos_right="10%")
)
)
line = Line().add_xaxis(name).add_yaxis("点击率", v3, yaxis_index=1)
bar.overlap(Iine)
bar.render_notebook()
然后在jupter上面运行此代码后显示错误,下面是系统显示的完整的错误原因。希望大家可以帮我看一下,百度后还是没有解决。
SpecificationError Traceback (most recent call last)
Input In [24], in
——> 1 data_date = data.groupby('date')['clk'].agg({
2 '展示量':'count',
3 '点击量':sum,
4 '点击率':np.mean
5 })
7 # 建立《2017/05/05至2017/05/13的广告点击情况》的柱形-折线图
8 from pyecharts import options as opts
File E\anaconda\lib\site-packages\pandas\core\groupby\generic.py:271, in SeriesGroupBy.aggregate(self, func, engine, engine_kwargs, *args, **kwargs)
267 elif isinstance(func, abc.Iterable):
268 # Catch instances of lists / tuples
269 # but not the class list / tuple itself.
270 func = maybe_mangle_lambdas(func)
--> 271 ret = self._aggregate_multiple_funcs(func)
272 if relabeling:
273 # error: Incompatible types in assignment (expression has type
274 # "Optional[List[str]]", variable has type "Index")
275 ret.columns = columns # type: ignore[assignment]
File E:\anaconda\lib\site-packages\pandas\core\groupby\generic.py:307, in SeriesGroupBy._aggregate_multiple_funcs(self, arg)
301 def _aggregate_multiple_funcs(self, arg) -> DataFrame:
302 if isinstance(arg, dict):
303
304 # show the deprecation, but only if we
305 # have not shown a higher level one
306 # GH 15931
-> 307 raise SpecificationError("nested renamer is not supported")
309 elif any(isinstance(x, (tuple, list)) for x in arg):
310 arg = [(x, x) if not isinstance(x, (tuple, list)) else x for x in arg]
SpecificationError: nested renamer is not supported