-1

I've tried to import a csv file created with pandas dataframe to gephi, but the file doesn't show peoperly.

I made a dataframe in python pandas and exported this way.

df.to_csv("df_gephi.csv", encoding="utf_8")

*I've tried encoding="utf_8_sig" as well.

And I imported the file to gephi with "utf-8" file option, but all the characters turn out to be squares instead when visualizing it. Any tips will be appreciated.

I have an additional data set I want to work out with gephi.

DATA1

First data

DATA2

enter image description here

user9191983
  • 505
  • 1
  • 4
  • 20
  • 1
    Have you tried exporting csv without using encoding option? – HT121 Feb 13 '19 at 14:34
  • For this type of data, I think encoding utf_8 or utf_8_sig should work. Can you open the exported csv file in Excel and see if text appears correctly there? If not, may be try exporting the data using df.to_excel() and see if text appears to be correct when you open the file in Excel. If text looks fine in Excel, then it is a problem somewhere in Gephi import. – HT121 Feb 14 '19 at 10:28
  • Thanks much! but it still shows squares instead of Japanese scrypt. I did ` df.to_excel('df.xlsx') ` and made sure that it appears correctly in Excel app... – user9191983 Feb 18 '19 at 04:36

1 Answers1

0

Not answering your question exactly, but you could give it a try by converting your network data (your dataframe, lets call it df) as an edge list with weights (if you have edge weights in your data) using networkx. You can then save that file as graphml file which you can open in Gephi without any issues.

For an edge list, you need to have a source node and target node together with weight (if present). Every row in your df must contain a source node and target node information in separate columns.

import networkx as nx

df_network = nx.from_pandas_dataframe(df,source='Src', target='Dst', edge_attr=["weight"], create_using=nx.DiGraph())
nx.write_graphml(df_network,'movement_net_charite.graphml') 

in this example, I have stored source node data in the column named 'Src', target node data in 'Dst' and weights in 'weight' columns.

HT121
  • 431
  • 2
  • 6
  • 14
  • Thanks much!! I added a little bite of my data. They appear that way and how can I practice your advice on my work? – user9191983 Feb 14 '19 at 07:02