wailsafi commited on
Commit
592e2da
·
1 Parent(s): fd7e1d2

pannel app

Browse files
Files changed (3) hide show
  1. app.py +48 -0
  2. dockerfile +13 -0
  3. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import panel as pn
3
+ import hvplot.pandas
4
+
5
+ # Load Data
6
+ from bokeh.sampledata.autompg import autompg_clean as df
7
+
8
+ # Make DataFrame Pipeline Interactive
9
+ idf = df.interactive()
10
+
11
+ # Define Panel widgets
12
+ cylinders = pn.widgets.IntSlider(name='Cylinders', start=4, end=8, step=2)
13
+ mfr = pn.widgets.ToggleGroup(
14
+ name='MFR',
15
+ options=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
16
+ value=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
17
+ button_type='success')
18
+ yaxis = pn.widgets.RadioButtonGroup(
19
+ name='Y axis',
20
+ options=['hp', 'weight'],
21
+ button_type='success'
22
+ )
23
+
24
+ # Combine pipeline and widgets
25
+ ipipeline = (
26
+ idf[
27
+ (idf.cyl == cylinders) &
28
+ (idf.mfr.isin(mfr))
29
+ ]
30
+ .groupby(['origin', 'mpg'])[yaxis].mean()
31
+ .to_frame()
32
+ .reset_index()
33
+ .sort_values(by='mpg')
34
+ .reset_index(drop=True)
35
+ )
36
+
37
+ # Pipe to hvplot
38
+ ihvplot = ipipeline.hvplot(x='mpg', y=yaxis, by='origin', color=["#ff6f69", "#ffcc5c", "#88d8b0"], line_width=6, height=400)
39
+
40
+ # Layout using Template
41
+ template = pn.template.FastListTemplate(
42
+ title='Interactive DataFrame Dashboards with hvplot .interactive',
43
+ sidebar=[cylinders, 'Manufacturers', mfr, 'Y axis' , yaxis],
44
+ main=[ihvplot.panel()],
45
+ accent_base_color="#88d8b0",
46
+ header_background="#88d8b0",
47
+ )
48
+ template.servable()
dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ RUN useradd -m -u 1000 user
4
+ USER user
5
+ ENV PATH="/home/user/.local/bin:$PATH"
6
+
7
+ WORKDIR /app
8
+
9
+ COPY --chown=user ./requirements.txt requirements.txt
10
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
11
+
12
+ COPY --chown=user . /app
13
+ CMD ["panel", "serve","/code/app.py", "--address", "0.0.0.0", "--port", "7860", "allow-websocket-origin", "wailsafi-example1.hf.space"]
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ panel
2
+ hvplot