-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (62 loc) · 2.07 KB
/
main.py
File metadata and controls
78 lines (62 loc) · 2.07 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
76
77
78
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import yfinance as yf
from io import BytesIO
st.title('Учебный проект по визуализации данных')
st.write("Статистическая выдержка предприятия питания за 2023 г.")
tips = pd.read_csv('tips.csv')
st.write(tips.head(10))
# 1
st.subheader('Вариативность размера общего чека')
fig, ax = plt.subplots()
sns.histplot(data=tips, x='total_bill', ax=ax, kde=True, color='#0d88e6')
plt.xlabel('Total Bill, USD')
plt.ylabel('Number of orders')
st.pyplot(fig)
buf = BytesIO()
fig.savefig(buf, format="png")
buf.seek(0)
st.download_button('Скачать график',
data=buf,
file_name='Вариативность размера Общего Чека.png',
)
# 2
st.subheader('Тренд размера чаевых по дням недели')
st.bar_chart(data=tips,
x='day_of_week',
y='tip',
x_label='Day of the week',
y_label='Size of the tip, USD',
color='#0d88e6'
)
# 3
st.subheader('Чаевые vs. Общий Чек')
st.scatter_chart(data=tips,
x='total_bill',
y='tip',
x_label='Total Bill, USD',
y_label='Tip, USD',
color='#0d88e6'
)
# 4
st.subheader('Отношение Общего Чека и Размера Чаевых к Объему заказа')
g = sns.relplot(data=tips,
x='total_bill',
y='tip',
size='size',
aspect=1.4,
color='#0d88e6',
legend=False
);
plt.xlabel('Total Bill')
plt.ylabel('Tip, USD')
st.pyplot(g)
buf = BytesIO()
fig.savefig(buf, format="png")
buf.seek(0)
st.download_button('Скачать график',
data=buf,
file_name='Отношение Общего Чека и Размера Чаевых к Объему заказа.png',
)