Skip to content

Commit 3503a46

Browse files
committed
streamlit testing
1 parent b6407d2 commit 3503a46

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

streamlit/Dockerfile

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM continuumio/miniconda3:latest
2+
3+
MAINTAINER Anshul Jindal "anshul.jindal@tum.de"
4+
5+
RUN mkdir -p /home/streamlit
6+
WORKDIR /home/streamlit
7+
8+
RUN conda install --yes \
9+
numpy==1.16.3 \
10+
pandas==0.24.2 \
11+
&& conda clean -afy
12+
13+
RUN pip install streamlit
14+
RUN pip install xlrd
15+
16+
COPY . /home/streamlit
17+
18+
EXPOSE 8501
19+
20+
CMD [ "streamlit", "run", "web.py" ]

streamlit/m_1.xlsx

1.91 MB
Binary file not shown.

streamlit/web.py

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import streamlit as st
2+
import pandas as pd
3+
import numpy as np
4+
5+
st.title('Machine Resources Utilization')
6+
st.sidebar.title('Machine Resources Utilization')
7+
DATE_COLUMN = 'date/time'
8+
9+
@st.cache
10+
def load_data():
11+
data = pd.read_excel('m_1.xlsx')
12+
data.drop(['machine_id', 'mem_gps', 'mkpi'], axis=1, inplace=True)
13+
lowercase = lambda x: str(x).lower()
14+
data.rename(lowercase, axis='columns', inplace=True)
15+
data[DATE_COLUMN] = pd.to_datetime(data['timestamp'])
16+
return data
17+
18+
19+
data = load_data()
20+
hour_data_group = data.groupby(data[DATE_COLUMN].dt.hour)
21+
22+
st.sidebar.markdown('Interact with the data here')
23+
option = st.sidebar.selectbox(
24+
'Mean or Mean results to get ',
25+
['mean', 'median'])
26+
27+
'You have selected: ', option
28+
29+
# median stats
30+
if option == 'median':
31+
med_data = pd.DataFrame(data.groupby(data[DATE_COLUMN].dt.hour).median(),
32+
columns=['cpu_util_percent', 'mem_util_percent', 'net_in', 'net_out', 'disk_io_percent'])
33+
med_data.reset_index(inplace=True)
34+
med_data.drop([DATE_COLUMN], axis=1, inplace=True)
35+
st.subheader('Median Resources Utilization per hour of the day in the whole week')
36+
if st.sidebar.checkbox('Show raw data'):
37+
st.subheader('Raw data')
38+
med_data
39+
st.line_chart(med_data)
40+
st.subheader('Median Resources Utilization per minute for the selected hour of the day in the whole week')
41+
# Some number in the range 0-23
42+
hour_to_filter = st.sidebar.slider('hour', 0, 23, 17)
43+
hour_data = hour_data_group.get_group(hour_to_filter)
44+
hour_data
45+
hour_median_data = pd.DataFrame(hour_data.groupby(hour_data[DATE_COLUMN].dt.minute).median(),
46+
columns=['cpu_util_percent', 'mem_util_percent',
47+
'net_in', 'net_out', 'disk_io_percent'])
48+
hour_median_data.reset_index(inplace=True)
49+
hour_median_data.drop([DATE_COLUMN], axis=1, inplace=True)
50+
st.line_chart(hour_median_data)
51+
52+
53+
elif option == 'mean':
54+
mean_data = pd.DataFrame(data.groupby(data[DATE_COLUMN].dt.hour).mean(),
55+
columns=['cpu_util_percent', 'mem_util_percent', 'net_in', 'net_out', 'disk_io_percent'])
56+
mean_data.reset_index(inplace=True)
57+
mean_data.drop([DATE_COLUMN], axis=1, inplace=True)
58+
st.subheader('Mean Resources Utilization per hour of the day in the whole week')
59+
if st.sidebar.checkbox('Show raw data'):
60+
st.subheader('Raw data')
61+
mean_data
62+
st.line_chart(mean_data)
63+
st.subheader('Mean Resources Utilization per minute for the selected hour of the day in the whole week')
64+
# Some number in the range 0-23
65+
hour_to_filter = st.sidebar.slider('hour', 0, 23, 17)
66+
hour_data = hour_data_group.get_group(hour_to_filter)
67+
hour_data
68+
hour_mean_data = pd.DataFrame(hour_data.groupby(hour_data[DATE_COLUMN].dt.minute).mean(),
69+
columns=['cpu_util_percent', 'mem_util_percent',
70+
'net_in', 'net_out', 'disk_io_percent'])
71+
hour_mean_data.reset_index(inplace=True)
72+
hour_mean_data.drop([DATE_COLUMN], axis=1, inplace=True)
73+
st.line_chart(hour_mean_data)
74+
75+
76+
77+
78+
79+
80+
81+

0 commit comments

Comments
 (0)