-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtwittergraph.py
More file actions
executable file
·75 lines (67 loc) · 2.42 KB
/
Copy pathtwittergraph.py
File metadata and controls
executable file
·75 lines (67 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from twitterprocess import top_results
from Senti import analyse_sentiment
import plotly.graph_objs as go
#FUNCTION TO PLOT TWITTER GRAPHS
def TWT_graph(n_clicks,input_value):
andf = top_results(input_value)
andf = analyse_sentiment(andf,"text")
andf['Date'] = andf.apply(lambda row: str(row.timestamp).split(" ", 1)[0], axis = 1)
andf['RoundPolarity'] = round(andf['sentiment'],1)
andf2 = andf.groupby('Date', as_index=False)[['sentiment']].mean()
# ansdf3 = ansdf.groupby('RoundPolarity', as_index=False)[['Likes']].sum()
data=[]
trace_close = go.Scatter(x = list(andf2.Date),
y=list(andf2.sentiment),
name="Close",
line=dict(color="#ff3333"))
data.append(trace_close)
figure1 = go.Figure(data)
figure1.update_layout(
title="Date-Wise Mean Sentiment Score Line Plot",
xaxis_title="Date",
yaxis_title="Mean Score",
template='plotly_dark',
plot_bgcolor= 'rgba(0, 0, 0, 0)'
)
data=[]
trace_close = go.Scatter(x = list(andf.timestamp),
y=list(andf.sentiment),
mode='markers',
name="markers",
marker_color=andf['sentiment'])
data.append(trace_close)
figure2 = go.Figure(data)
figure2.update_layout(
title="Date-Wise Sentiment Score Scatter Plot [negative(-1) to positive(+1)]",
xaxis_title="Date",
yaxis_title="(-ve) Sentiment Score (+ve)",
template='plotly_dark',
plot_bgcolor= 'rgba(0, 0, 0, 0)'
)
data=[]
trace_close = go.Box(x = list(andf.Date),
y=list(andf.sentiment),
name="Close",
line=dict(color="#ff3333"))
data.append(trace_close)
figure3 = go.Figure(data)
figure3.update_layout(
title="Date-Wise Sentiment Score Box Plot [negative(-1) to positive(+1)]",
xaxis_title="Date",
yaxis_title="(-ve) Sentiment Score (+ve)",
template='plotly_dark',
plot_bgcolor= 'rgba(0, 0, 0, 0)'
)
data=[]
trace_close = go.Pie(labels=list(andf.roundoff),
name="Close"
)
data.append(trace_close)
figure4 = go.Figure(data)
figure4.update_layout(
title="Pie-Chart",
template='plotly_dark',
plot_bgcolor= 'rgba(0, 0, 0, 0)'
)
figure = (figure1,figure2,figure3,figure4)
return figure