#获取指数成份股权重
df=get_index_weights('000300.XSHG')
#根据权重降序排列取前十只股票
df=df.sort_values('weight',ascending=False).iloc[:10,:]
#绘制柱状图
from pyecharts import options as opts
from pyecharts.charts import Bar
c=Bar()
c.add_xaxis(list(df.loc[:,'display_name']))
c.add_yaxis('权重',list(df.loc[:,'weight']))
c.render_notebook()