-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.py
52 lines (45 loc) · 1.73 KB
/
misc.py
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
def graphs():
#total_investment=int(df_selection["Investment"]).sum()
#averageRating=int(round(df_selection["Rating"]).mean(),2)
#simple bar graph
investment_by_business_type=(
df_selection.groupby(by=["BusinessType"]).count()[["Investment"]].sort_values(by="Investment")
)
fig_investment=px.bar(
investment_by_business_type,
x="Investment",
y=investment_by_business_type.index,
orientation="h",
title="<b> Investment by Business Type </b>",
color_discrete_sequence=["#0083B8"]*len(investment_by_business_type),
template="plotly_white",
)
fig_investment.update_layout(
plot_bgcolor="rgba(0,0,0,0)",
xaxis=(dict(showgrid=False))
)
#simple line graph
investment_state=df_selection.groupby(by=["State"]).count()[["Investment"]]
fig_state=px.line(
investment_state,
x=investment_state.index,
y="Investment",
orientation="v",
title="<b> Investment by State </b>",
color_discrete_sequence=["#0083b8"]*len(investment_state),
template="plotly_white",
)
fig_state.update_layout(
xaxis=dict(tickmode="linear"),
plot_bgcolor="rgba(0,0,0,0)",
yaxis=(dict(showgrid=False))
)
left,right,center=st.columns(3)
left.plotly_chart(fig_state,use_container_width=True)
right.plotly_chart(fig_investment,use_container_width=True)
with center:
#pie chart
fig = px.pie(df_selection, values='Rating', names='State', title='Regions by Ratings')
fig.update_layout(legend_title="Regions", legend_y=0.9)
fig.update_traces(textinfo='percent+label', textposition='inside')
st.plotly_chart(fig, use_container_width=True, theme=theme_plotly)