如何解决将 Pandas DataFrame 转换为 igraph
我想从 excel 中读取并在 igraph 中使用输出。我的代码是:
import igraph as ig import pandas as pd
data=pd.read_excel(r'example.xlsx')
df=pd.DataFrame(data,columns=['product'])
g=ig.Graph.TupleList(df.itertuples(index=False),directed=True)
print(g)
edge_list.append((idgen[item[0]],idgen[item[1]])) IndexError: tuple
index out of range
我的excel图表是:
Product Price
desktop computer 700
laptop 250
printer 120
tablet 1200
我使用 pycharm。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。