Netowrkx len() command giving a 'str' object error

泄露秘密 提交于 2021-01-29 07:10:34

问题


To start, I created a Network using 2014 flight data as explained here:https://ipython-books.github.io/142-drawing-flight-routes-with-networkx/

I'm trying to create smaller graphs using airline specific flight paths to test connectivity within each business, starting with American Airlines, I did the following:

AASys = routes[
    routes['source'].isin(airports_us.index) &
    routes['dest'].isin(airports_us.index) &
    routes['airline'].str.contains('AA')]
AASys

AAedges = AASys[['source', 'dest']].values
AAedges

AAg = nx.from_edgelist(AAedges)

len(AAg.nodes()), len(AAg.edges())

This mirrors the tutorial input almost exactly, with the only change being the additional str.contains('AA'). But when I try to test the len() of my new database, I get -- TypeError: 'str' object is not callable.

Can anyone explain why my edgelist is reading as a string? How to I fix the TypeError?

来源:https://stackoverflow.com/questions/64938019/netowrkx-len-command-giving-a-str-object-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!