In [12]:
import pandas as pd
from faker import Factory
fake = Factory.create()
first_authors = pd.DataFrame(index=[fake.name() for i in range(0,50)])
first_authors.head()
Out[12]:
In [27]:
second_authors = pd.DataFrame(index=[fake.name() for i in range(0,50)])
second_authors.head()
Out[27]:
In [45]:
ranges = pd.DatetimeIndex(
start=pd.Timestamp("2014"),
end=pd.Timestamp("2016"),
freq="W"
)
makers = pd.DataFrame(ranges, columns=["date"])
makers["key"] = first_authors.sample(len(makers), replace=True).index
makers["value"] = makers['key'].apply(lambda x : fake.numerify())
makers.head()
Out[45]:
In [46]:
ranges = pd.DatetimeIndex(
start=pd.Timestamp("2016"),
end=pd.Timestamp("2018"),
freq="W")
menders = pd.DataFrame(ranges, columns=["date"])
menders["key"] = second_authors.sample(len(menders), replace=True).index
menders["value"] = menders['key'].apply(lambda x : fake.numerify())
menders.head()
Out[46]:
In [47]:
modifications_over_time = pd.concat([makers, menders])
modifications_over_time.head()
Out[47]:
In [49]:
modifications_over_time = modifications_over_time.reindex(columns=["key", "value", "date"])
csv_filename = "interactive_steamgraph_synthetic.csv"
modifications_over_time.to_csv("vis/" + csv_filename, index=False)
with open("vis/interactive_steamgraph_template.html", "r") as template:
content = template.read()
content = content.replace("${FILENAME}", csv_filename)
with open("vis/interactive_steamgraph_synthetic.html", "w") as output_file:
output_file.write(content)
modifications_over_time.head()
Out[49]: