cleaned the code
This commit is contained in:
parent
ed7a9eed80
commit
6badc6da48
|
|
@ -44,7 +44,7 @@ def main():
|
|||
for p in participants:
|
||||
print(f"{p.name}\n")
|
||||
|
||||
#analyzing.make_wordcloud(WORDS_IN_CHAT)
|
||||
analyzing.make_wordcloud(WORDS_IN_CHAT)
|
||||
analyzing.make_timeline(participants)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ from PIL import Image
|
|||
from os import path
|
||||
import pandas as pd
|
||||
import plotly.express as px
|
||||
import plotly.graph_objs as go
|
||||
from participant import Participant
|
||||
|
||||
|
||||
def incidents_of_words(words):
|
||||
|
|
@ -22,10 +20,6 @@ def incidents_of_words(words):
|
|||
|
||||
|
||||
def create_dataframe(participants):
|
||||
# m_df = {}
|
||||
# sender = []
|
||||
# date = []
|
||||
# message = []
|
||||
skeleton = {"month": [],
|
||||
"counts": [],
|
||||
"sender": []}
|
||||
|
|
@ -33,10 +27,8 @@ def create_dataframe(participants):
|
|||
for p in participants:
|
||||
date=[]
|
||||
date += (p.messages.keys())
|
||||
# print(len(date))
|
||||
message=[]
|
||||
message += (p.messages.values())
|
||||
# print(len(message))
|
||||
|
||||
m_di = {"date": date,
|
||||
"message": message}
|
||||
|
|
@ -52,12 +44,8 @@ def create_dataframe(participants):
|
|||
sender += [p.name]*df_month.count()[0]
|
||||
|
||||
df_month["sender"] = sender
|
||||
# gfg_csv_data = pd.DataFrame(df_month).to_csv('GfGbbbbb.csv', index = True)
|
||||
|
||||
df = pd.concat([df, df_month])
|
||||
|
||||
|
||||
# gfg_csv_data = pd.DataFrame(df).to_csv('GfGaaaa.csv', index = True)
|
||||
|
||||
return pd.DataFrame(df)
|
||||
|
||||
|
|
@ -90,20 +78,8 @@ def make_wordcloud(WORDS_IN_CHAT):
|
|||
def make_timeline(participants):
|
||||
df = create_dataframe(participants)
|
||||
|
||||
# by_month = pd.to_datetime(df['date']).dt.to_period('M').value_counts().sort_index()
|
||||
# by_month.index = pd.PeriodIndex(by_month.index)
|
||||
# df_month = by_month.rename_axis('month').reset_index(name='counts')
|
||||
|
||||
# fig = go.Figure(data=go.Scatter(x=df_month['month'].astype(dtype=str),
|
||||
# y=df_month['counts'],
|
||||
# marker_color='indianred', text="counts"))
|
||||
# fig = go.Figure()
|
||||
# for sender, group in df.groupby("sender"):
|
||||
# fig.add_trace(go.Scatter(x=group["month"].to_list(), y=group["counts"].to_list(), name=sender))
|
||||
# fig = px.line(df_month, x='month', y='counts')
|
||||
|
||||
fig = px.line(df, x="month", y="counts", color="sender")
|
||||
fig.update_layout({ "showlegend": False,
|
||||
fig.update_layout({ "showlegend": True,
|
||||
"title": {"text": "Timeline of Messages",
|
||||
"xanchor": "center",
|
||||
"x": 0.5},
|
||||
|
|
@ -115,8 +91,5 @@ def make_timeline(participants):
|
|||
"paper_bgcolor": 'rgba(0,0,0,0)',
|
||||
"plot_bgcolor": 'rgba(0,0,0,0)'
|
||||
})
|
||||
# fig.show()
|
||||
|
||||
fig.write_image("by-month.png",format="png", width=1500, height=600, scale=3)
|
||||
|
||||
# saving the DataFrame as a CSV file
|
||||
# gfg_csv_data = df.to_csv('GfG.csv', index = True)
|
||||
|
|
|
|||
Loading…
Reference in New Issue