sheraznaseer commited on
Commit
7273d30
1 Parent(s): a0f1050

added the code, dockerfile and requirements.txt

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. Dockerfile +11 -0
  3. app.py +48 -0
  4. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .vscode/
2
+ .gitattributes
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ WORKDIR /code
4
+
5
+ COPY ./requirements.txt /code/requirements.txt
6
+
7
+ RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["panel", "serve", "/code/app.py", "--address", "0.0.0.0","--port", "7860", "--allow-websocket-origin", "sheraznaseer-test_panelapp_2304.hf.space"]
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import panel as pn
2
+ import hvplot.pandas
3
+
4
+ # Load Data
5
+ from bokeh.sampledata.autompg import autompg_clean as df
6
+
7
+ # Make DataFrame Pipeline Interactive
8
+ idf = df.interactive()
9
+
10
+ # Define Panel widgets
11
+ cylinders = pn.widgets.IntSlider(name='Cylinders', start=4, end=8, step=2)
12
+ mfr = pn.widgets.ToggleGroup(
13
+ name='MFR',
14
+ options=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
15
+ value=['ford', 'chevrolet', 'honda', 'toyota', 'audi'],
16
+ button_type='success')
17
+ yaxis = pn.widgets.RadioButtonGroup(
18
+ name='Y axis',
19
+ options=['hp', 'weight'],
20
+ button_type='success'
21
+ )
22
+
23
+ # Combine pipeline and widgets
24
+ ipipeline = (
25
+ idf[
26
+ (idf.cyl == cylinders) &
27
+ (idf.mfr.isin(mfr))
28
+ ]
29
+ .groupby(['origin', 'mpg'])[yaxis].mean()
30
+ .to_frame()
31
+ .reset_index()
32
+ .sort_values(by='mpg')
33
+ .reset_index(drop=True)
34
+ )
35
+
36
+ # Pipe to hvplot
37
+ ihvplot = ipipeline.hvplot(x='mpg', y=yaxis, by='origin', color=[
38
+ "#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()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ bokeh==3.1.0
2
+ hvplot==0.8.3
3
+ panel==0.14.4