Я работаю со словарями и у меня возникла следующая ошибка
'>' not supported between instances of 'dict' and 'dict'
Я знаю, что есть некоторые проблемы со словарями в версиях Python 2.7 и 3.x.
print("number of nodes %d" % G.number_of_nodes())
print("number of edges %d" % G.number_of_edges())
print("Graph is connected?: %s" % nx.is_connected(G))
print("Number of connected components: %s" % nx.number_connected_components(G))
print("Size of connected componnents: %s" % [len(cc) for cc in nx.connected_components(G)])
print("Network Analysis will be performed on the largest cc from now on")
largest_cc = max(nx.connected_component_subgraphs(G), key=len)
dict_communities={}
num_communities=max([y for x,y in largest_cc.nodes(data=True)]).values()[0]
for i in range (1,num_communities+1):
dict_communities = [x for x,y in largest_cc.nodes(data=True) if y['community']==i]
TypeError Traceback (most recent call last)
in
1 dict_communities={}
----> 2 num_communities=max([y for x,y in largest_cc.nodes(data=True)])[0]
3 for i in range (1,num_communities+1):
4 dict_communities = [x for x,y in largest_cc.nodes(data=True) if y['community']==i]
TypeError: '>' not supported between instances of 'dict' and 'dict'
Подробнее здесь: https://stackoverflow.com/questions/564 ... t-and-dict
TypeError: '>' не поддерживается между экземплярами 'dict' и 'dict' ⇐ Python
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
«Ошибка типа: '<=' не поддерживается между экземплярами 'dict' и 'float'»
Anonymous » » в форуме Python - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-
-
-
«Ошибка типа: '<=' не поддерживается между экземплярами 'dict' и 'float'» [закрыто]
Anonymous » » в форуме Python - 0 Ответы
- 13 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Ключ SortedDict: TypeError: '<' не поддерживается между экземплярами 'str' и 'int'
Anonymous » » в форуме Python - 0 Ответы
- 15 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Python — TypeError: «<» не поддерживается между экземплярами «NoneType» и «float»
Anonymous » » в форуме Python - 0 Ответы
- 17 Просмотры
-
Последнее сообщение Anonymous
-