forked from LukichevaPolina/Fintech-Securety-Superhero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopular.py
35 lines (23 loc) · 996 Bytes
/
popular.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
import edit_data
import plotly.graph_objects as go
feature_company = edit_data.feature_companies
#получение отсортированных по популярности features
def get_popular() -> list:
popularity = {}
for feature, companies in feature_company.items():
popularity[feature] = len(companies)
list_items = list(popularity.items())
list_items.sort(key=lambda i: i[1])
return list_items
popularity = get_popular()
def draw_popular(popularity):
colors = ["#2FA465", ] * len([popularity[i][0] for i in range(len(popularity))])
colors[len(popularity) - 1] = 'crimson'
fig = go.Figure(data=[go.Bar(
x=[popularity[i][0] for i in range(len(popularity))],
y=[popularity[i][1] for i in range(len(popularity))],
marker_color=colors)]) # marker color can be a single color value or an iterable
fig.update_layout(title_text='The most popular data')
fig.show()
return fig
draw_popular(popularity)