微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

AttributeError:类型对象“ Graph”没有属性“ DataFrame”

如何解决AttributeError:类型对象“ Graph”没有属性“ DataFrame”

我正在使用python-igraph

运行以下代码

import pandas as pd
d = {'col1':[1,2,3,4,5],'col2':[11,12,13,14,15]}
ct = pd.DataFrame(data=d)
from igraph import Graph,plot
g = Graph.DataFrame(edges=ct)
layout = g.layout('tree')
plot(g,layout = layout)

它会引发rhis错误

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-30-fc1ba82e7692> in <module>
      1 from igraph import *
----> 2 g = Graph.DataFrame(edges=ct)
      3 layout = g.layout('tree')
      4 plot(g,layout = layout)

AttributeError: type object 'Graph' has no attribute 'DataFrame'

但是在documentation of python-igraph中,实现了DataFrame函数。我不确定为什么会出现此错误。请帮忙!

解决方法

该文档比已实施的文档要新一些。新版本将于下周出现,该功能将可用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。