Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread ashutosh
I got the problem.

Graph Tool by default accepts only vertex objects or int(index) values on
edge list and hence either I pass on vertex object list or keep the options*
hashed=True and string_vals=True* in the add_edge_list option.

The problem is resolved now. Thank you



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread ashutosh
sampleFile.tab

  

above is the sample file.

and below is the code that produces the error as i mentioned before

import pandas as pd
import graph_tool.all as gtx
df = pd.read_csv("file_path",sep='\t',headers=True)

myGraph = gtx.Graph()

myGraph.add_edge_list(df.values.tolist())



--
Sent from: 
http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread Alexandre Hannud Abdo
Tiny typo, the first argument is `hashed=True`.

On Wed, Jul 18, 2018 at 1:18 PM, Alexandre Hannud Abdo 
wrote:

> Ni! Hi ashu,
>
> Please, always try to *read errors carefully* and consult the
> documentation. Not to mention, provide self-contained examples.
>
> Python is throwing a "TypeError" and telling you it expects an integer
> ('unsigned long', the C++ type for vertex indices) while you are passing it
> a string ('str').
>
> As you can see in the documentation
> , if you want to
> pass strings to add_edge_list you should set two additional arguments:
> `hash=True` and `string_vals=True`.
>
> If that doesn't fix it, you'll have to provide a self-contained example
> where the error occurs, otherwise we can't really help.
>
> .~´
>
>
>
> On Wed, Jul 18, 2018 at 9:37 AM, ashutosh  wrote:
>
>> Hi,
>>
>> I'm trying to convert two columns of my pandas dataframe into network
>> using
>> them as edge list.
>> A  similar query
>> > ding-edge-lists-from-pandas-dataframe>
>> was posted in StackOverflow but with different problem and it didn't help
>> me.
>>
>> When I am trying the following code it gives me error:
>> *
>> myGraph.add_edge_list(i for i in df[['node1','node2']].values.tolist())*
>>
>> Where, my Graph is the graph;  df is the dataframe with 4 columns out of
>> which I am using two 'node1' and 'node2'.
>>
>> *File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line
>> 2109, in
>> add_edge_list
>> libcore.add_edge_list_iter(self.__graph, edge_list, eprops)*
>>
>> *TypeError: No registered converter was able to produce a C++ rvalue of
>> type
>> unsigned long from this Python object of type str
>> *
>>
>>
>> I tried upgrading my boost library but it doesn't solve the problem. Any
>> suggestions ?
>>
>>
>>
>> --
>> Sent from: http://main-discussion-list-for-the-graph-tool-project.98248
>> 0.n3.nabble.com/
>> ___
>> graph-tool mailing list
>> graph-tool@skewed.de
>> https://lists.skewed.de/mailman/listinfo/graph-tool
>>
>
>
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool


Re: [graph-tool] TypeError while using add_edge_list

2018-07-18 Thread Alexandre Hannud Abdo
Ni! Hi ashu,

Please, always try to *read errors carefully* and consult the
documentation. Not to mention, provide self-contained examples.

Python is throwing a "TypeError" and telling you it expects an integer
('unsigned long', the C++ type for vertex indices) while you are passing it
a string ('str').

As you can see in the documentation
, if you want to
pass strings to add_edge_list you should set two additional arguments:
`hash=True` and `string_vals=True`.

If that doesn't fix it, you'll have to provide a self-contained example
where the error occurs, otherwise we can't really help.

.~´



On Wed, Jul 18, 2018 at 9:37 AM, ashutosh  wrote:

> Hi,
>
> I'm trying to convert two columns of my pandas dataframe into network using
> them as edge list.
> A  similar query
>  reading-edge-lists-from-pandas-dataframe>
> was posted in StackOverflow but with different problem and it didn't help
> me.
>
> When I am trying the following code it gives me error:
> *
> myGraph.add_edge_list(i for i in df[['node1','node2']].values.tolist())*
>
> Where, my Graph is the graph;  df is the dataframe with 4 columns out of
> which I am using two 'node1' and 'node2'.
>
> *File "/usr/lib/python3/dist-packages/graph_tool/__init__.py", line 2109,
> in
> add_edge_list
> libcore.add_edge_list_iter(self.__graph, edge_list, eprops)*
>
> *TypeError: No registered converter was able to produce a C++ rvalue of
> type
> unsigned long from this Python object of type str
> *
>
>
> I tried upgrading my boost library but it doesn't solve the problem. Any
> suggestions ?
>
>
>
> --
> Sent from: http://main-discussion-list-for-the-graph-tool-project.
> 982480.n3.nabble.com/
> ___
> graph-tool mailing list
> graph-tool@skewed.de
> https://lists.skewed.de/mailman/listinfo/graph-tool
>
___
graph-tool mailing list
graph-tool@skewed.de
https://lists.skewed.de/mailman/listinfo/graph-tool