我正在尝试条形图绘制列表中每个元素的数量:
x=[1,1,2]
list_pd = pd.DataFrame({'DrawnCards':x})
list_pd.head()
list_pd = list_pd.groupby('DrawnCards')['DrawnCards'].count()
DrawnCards
1 2
2 1
Name: DrawnCards, dtype: int64
plt.bar(list_pd.DrawnCards)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-117-7f4d4efd9a31> in <module>()
----> 1 plt.bar(list_pd.DrawnCards)
C:\Users\mesme\Anaconda3\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
2968 if name in self._info_axis:
2969 return self[name]
-> 2970 return object.__getattribute__(self, name)
2971
2972 def __setattr__(self, name, value):
AttributeError: 'Series' object has no attribute 'DrawnCards'
所以我需要把序列类型改成数据帧吗?我对这个有点迷恋。你知道吗
尝试直接调用序列的
plot
方法。你知道吗或者,使用
plt.bar
:相关问题 更多 >
编程相关推荐