In [1]:
import json
import pandas as pd
import numpy as np
In [16]:
hts = pd.read_csv("data/top_hashtags.csv")
# Should have made a better query
hts.head()
Out[16]:
In [17]:
min_deg = hts["deg"].min()
min_deg
Out[17]:
In [18]:
max_deg = hts["deg"].max()
max_deg
Out[18]:
In [19]:
converted = [{"text": "#" + json.loads(row[1]["n"])["hashtag"],
"size": np.interp(row[1]["deg"], [min_deg, max_deg], [5, 100])} for row in hts.iterrows()]
In [20]:
f = open('data/hashtag_sizes.js', 'w')
json.dump(converted, f)
f.close()
In [ ]: