In [8]:
import pandas as pd
import math
df = pd.read_csv("dataframe_cleaned_170408.csv", encoding='utf-8', index_col=0)
In [9]:
df.drop('url',axis=1,inplace=True)
df.drop('total_hours_played',axis=1,inplace=True)
In [10]:
df.head()
Out[10]:
In [22]:
nodes_weights = {}
for index, col in df.iteritems():
nodes_weights[index] = math.log(col.sum(),2)
In [28]:
with open("nodes_weights.csv", 'w', encoding='utf-8') as file:
file.write("Id\tLabel\tSize\n")
for key, value in nodes_weights.items():
file.write(key+"\t"+key+"\t"+str(value)+"\n")
In [ ]: