使用列表值进行Python_切片

使用列表值进行Python_切片,python,pandas,matplotlib,slice,legend,Python,Pandas,Matplotlib,Slice,Legend,我有一份价值清单: top_10_platf=platf_sales_top10['platform'].tolist() top_10_platf 输出: >>['PS2', 'X360', 'PS3', 'Wii', 'PS', 'DS', 'PS4', 'GBA', 'GB', 'NES'] 另外,我还有df,我想将其作为切片和构建图的过滤器执行top\u 10\u platf列表,因此: platf_sales_top10=platf_sales_top10.query(

我有一份价值清单:

top_10_platf=platf_sales_top10['platform'].tolist()
top_10_platf
输出:

>>['PS2', 'X360', 'PS3', 'Wii', 'PS', 'DS', 'PS4', 'GBA', 'GB', 'NES']
另外,我还有df,我想将其作为切片和构建图的过滤器执行
top\u 10\u platf
列表,因此:

platf_sales_top10=platf_sales_top10.query('platform==@top_10_platf')
fig, ax = plt.subplots(figsize=(15,7))
platf_sales_top10.groupby(['year_of_release','platform']).count()['global_sales'].unstack().plot(ax=ax)
plt.show()
但在最后,我得到了所有值的图例,但不是来自
top\u 10\u platf
列表。我需要在这里更正什么