python - 绘制熊猫数据框
问题描述
嗨,我最近在正常工作的代码上遇到了错误。无法将“numpy.generic”对象的“<attribute 'dtype'>”解释为数据类型。因此,我阅读了有关此错误的在线评论并进行了 conda 更新 pandas,因为人们认为 numy 版本 1.20.1 可能存在不兼容问题。Now I get a new error as matplotlib is required for plotting when the default backend "matplotlib" is selected. 我怎样才能让情节发挥作用。这是一个来自 pandas 数据框的简单绘图例程
df1 = pd.DataFrame({'word':wordlist, 'count':countlist})
ax=df1.plot.bar(color='g')
ax.set_xlabel(" word")
ax.set_ylabel("Count")
pl.suptitle("Year 2012")
ImportError Traceback (most recent call last)
<ipython-input-22-81ba99f051c4> in <module>
56 #seri=seri.sort_values('countlist')
57
---> 58 ax=df1.plot.bar(color='g')
59 ax.set_xlabel("Technology word")
60 ax.set_ylabel("Count")
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in bar(self, x, y, **kwargs)
1001 >>> axes = df.plot.line(
1002 ... subplots=True, color={"pig": "pink", "horse": "#742802"}
-> 1003 ... )
1004
1005 .. plot::
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in __call__(self, *args, **kwargs)
765 _dataframe_kinds = ("scatter", "hexbin")
766 _kind_aliases = {"density": "kde"}
--> 767 _all_kinds = _common_kinds + _series_kinds + _dataframe_kinds
768
769 def __init__(self, data):
~\Anaconda3\lib\site-packages\pandas\plotting\_core.py in _get_plot_backend(backend)
1667 the matplotlib function that is used under the hood.
1668
-> 1669 Examples
1670 --------
1671 The following examples are generated with random data from
ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected.
解决方案
推荐阅读
- r - 从一个点确定多个邮政编码之间的距离
- linux - 如何限制 Linux 中程序的网络带宽?
- sql - 您可以使用 IS NOT NULL 和通配符作为搜索参数吗
- angularjs - ng-repeat 过滤器的奇怪行为
- c# - 编辑表格条目后如何重新路由并刷新上一页?
- javascript - 将对象转换为数字(数组)
- c# - 优化解析文本文件,然后上传到Excel
- c# - 根据 DataGridView 选择显示图像会引发错误
- java - 使用 JSlider 更改图像亮度
- python - 检查给定的 *args 和 **kwargs 是否满足给定的函数签名(python2中的Signature.bind())