Marcelo commited on
Commit
398a3b1
·
1 Parent(s): 5bfe129

panel app

Browse files
Files changed (3) hide show
  1. Dockerfile +14 -0
  2. app.py +42 -0
  3. requirements.txt +2 -0
Dockerfile ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
2
+ # you will also find guides on how best to write your Dockerfile
3
+
4
+ FROM python:3.9
5
+
6
+ WORKDIR /code
7
+
8
+ COPY ./requirements.txt /code/requirements.txt
9
+
10
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
11
+
12
+ COPY . .
13
+
14
+ CMD ["panel", "serve", "/code/app.py","--address", "0.0.0.0", "--port", "7860", "--allow-websocket-origin","easysci-panel-main.hf.space"]
app.py CHANGED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import panel as pn
2
+ import hvplot.pandas
3
+ import param
4
+
5
+ # Load Data
6
+ from bokeh.sampledata.autompg import autompg_clean as df
7
+
8
+ # create a self-contained dashboard class
9
+ class InteractiveDashboard(param.Parameterized):
10
+ cylinders = param.Integer(label='Cylinders', default=4, bounds=(4, 8))
11
+ mfr = param.ListSelector(
12
+ label='MFR',
13
+ default=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
14
+ objects=['ford', 'chevrolet', 'honda', 'toyota', 'audi'], precedence=0.5)
15
+ yaxis = param.Selector(label='Y axis', objects=['hp', 'weight'])
16
+
17
+
18
+ @param.depends('cylinders', 'mfr', 'yaxis')
19
+ def plot(self):
20
+ return (
21
+ df[
22
+ (df.cyl == self.cylinders) &
23
+ (df.mfr.isin(self.mfr))
24
+ ]
25
+ .groupby(['origin', 'mpg'])[self.yaxis].mean()
26
+ .to_frame()
27
+ .reset_index()
28
+ .sort_values(by='mpg')
29
+ .reset_index(drop=True)
30
+ .hvplot(x='mpg', y=self.yaxis, by='origin', color=["#ff6f69", "#ffcc5c", "#88d8b0"], line_width=6, height=400)
31
+ )
32
+ dashboard = InteractiveDashboard()
33
+
34
+ # Layout using Template
35
+ template = pn.template.FastListTemplate(
36
+ title='Interactive DataFrame Dashboards with param .depends',
37
+ sidebar=[pn.Param(dashboard.param, widgets={'mfr': pn.widgets.ToggleGroup,'yaxis': pn.widgets.RadioButtonGroup})],
38
+ main=[dashboard.plot],
39
+ accent_base_color="#88d8b0",
40
+ header_background="#88d8b0",
41
+ )
42
+ template.servable()
requirements.txt CHANGED
@@ -0,0 +1,2 @@
 
 
 
1
+ hvplot
2
+ panel