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]:
神明的一天世界(God's One Day World) ! That Bastard Is Trying To Steal Our Gold ! "Glow Ball" - The billiard puzzle game #SelfieTennis #SkiJump #killallzombies $1 Ride 'n Verlore Verstand - Arcane Raise - -- none -- [Not currently available] ... ファイナルファンタジーXIV: 新生エオルゼア (JP version) 丛林守望者(Ranger of the jungle) 乖離性ミリオンアーサー VR 侠客风云传(Tale of Wuxia) 大海战 Navy Field IV 天使帝國四《Empire of Angels IV》 画境(Picturesque) VR 神楽道中記(KaguraDouchuuki) 軒轅劍外傳穹之扉(The Gate of Firmament) 軒轅劍外傳穹之扉音樂精選集(Sound Collection of Xuan-Yuan Sword EX:The Gate of Firmament)
http://steamcommunity.com/id/drunkenf00l/games/?tab=all 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
http://steamcommunity.com/id/jacobu/games/?tab=all 0 0 0 0 1 0 0 0 0 0 ... 1 0 1 0 0 0 0 0 0 0
http://steamcommunity.com/id/mrhoten/games/?tab=all 0 0 0 1 1 0 0 0 0 0 ... 0 0 1 0 0 0 0 0 0 0
http://steamcommunity.com/id/AciD/games/?tab=all 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0
http://steamcommunity.com/id/afarnsworth/games/?tab=all 0 0 0 0 1 0 0 0 0 0 ... 0 0 1 0 0 0 0 0 0 0

5 rows × 12950 columns


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 [ ]: