TypeError while using add_edge_list


I'm trying to convert two columns of my pandas dataframe into network using
them as edge list.
A similar query
was posted in StackOverflow but with different problem and it didn't help

When I am trying the following code it gives me error:

Without a minimal and self-contained example that shows the problem, it's
difficult to say anything.

Please provide a small example that we can run, so we can understand what
the problem may be.

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
<https://graph-tool.skewed.de/static/doc/graph_tool.html&gt;, 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.


attachment.html (3.01 KB)

Tiny typo, the first argument is `hashed=True`.

attachment.html (3.5 KB)


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()


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